blob: 9128d3de7465e335c0aba6c97c4919e75817a95e [file] [log] [blame]
aitor-lunargd5301592022-01-05 22:38:16 +01001/* Copyright (c) 2015-2022 The Khronos Group Inc.
2 * Copyright (c) 2015-2022 Valve Corporation
3 * Copyright (c) 2015-2022 LunarG, Inc.
4 * Copyright (C) 2015-2022 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
sfricke-samsung2e827212021-09-28 07:52:08 -070027#include "core_validation_error_enums.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010028
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070029static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060030
John Zulauf71968502017-10-26 13:51:15 -060031template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070032inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060033 // Using only < for generality and || for early abort
34 return !((value < min) || (max < value));
35}
36
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -060037ReadLockGuard StatelessValidation::ReadLock() { return ReadLockGuard(validation_object_mutex, std::defer_lock); }
38WriteLockGuard StatelessValidation::WriteLock() { return WriteLockGuard(validation_object_mutex, std::defer_lock); }
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070039
Jeremy Gebbencbf22862021-03-03 12:01:22 -070040static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070041static ReadWriteLock secondary_cb_map_mutex;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -060042static ReadLockGuard CBReadLock() { return ReadLockGuard(secondary_cb_map_mutex); }
43static WriteLockGuard CBWriteLock() { return WriteLockGuard(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070044
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070045bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050046 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 bool skip = false;
48
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070049 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050
51 if (result == VK_STRING_ERROR_NONE) {
52 return skip;
53 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070054 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070055 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060056 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070057 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
58 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060059 }
60 return skip;
61}
62
Jeff Bolz46c0ea02019-10-09 13:06:29 -050063bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060064 bool skip = false;
65 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
66 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080067 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
68 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070069 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
70 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
71 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060072 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070073 skip |= LogWarning(instance, kVUIDUndefined,
74 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
75 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
76 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060077 }
78 }
79 return skip;
80}
81
Jeff Bolz46c0ea02019-10-09 13:06:29 -050082bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060083 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060084 // Create and use a local instance extension object, as an actual instance has not been created yet
85 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
86 InstanceExtensions local_instance_extensions;
87 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
88
John Zulauf620755c2018-04-16 11:00:43 -060089 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060090 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
91 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060092 }
93
94 return skip;
95}
96
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060097bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -070098 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060099 // Struct is legal IF it's supported
100 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
101 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
102 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
103 if (enum_iter != dev_exts_enumerated->second.cend()) {
104 return true;
105 }
106 }
107 return false;
108}
109
Tony-LunarG866843d2020-05-13 11:22:42 -0600110bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
111 const VkValidationFeaturesEXT *validation_features) const {
112 bool skip = false;
113 bool debug_printf = false;
114 bool gpu_assisted = false;
115 bool reserve_slot = false;
116 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
117 switch (validation_features->pEnabledValidationFeatures[i]) {
118 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
119 gpu_assisted = true;
120 break;
121
122 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
123 debug_printf = true;
124 break;
125
126 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
127 reserve_slot = true;
128 break;
129
130 default:
131 break;
132 }
133 }
134 if (reserve_slot && !gpu_assisted) {
135 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
136 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
137 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
138 }
139 if (gpu_assisted && debug_printf) {
140 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
141 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
142 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
143 }
144
145 return skip;
146}
147
John Zulauf620755c2018-04-16 11:00:43 -0600148template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700149ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
150 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600151 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700152 ExtEnabled state =
153 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600154 return state;
155}
156
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700157bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500158 const VkAllocationCallbacks *pAllocator,
159 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700160 bool skip = false;
161 // Note: From the spec--
162 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
163 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
164 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700165 ? pCreateInfo->pApplicationInfo->apiVersion
166 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700167 skip |= validate_api_version(local_api_version, api_version);
168 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700169 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600170 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
171
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700172 return skip;
173}
174
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700175void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700176 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
177 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700178 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
179 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700180 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700181 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700182}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600183
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700184void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
185 // Assume phys_devices is valid
186 assert(phys_devices);
187 for (int i = 0; i < count; ++i) {
188 const auto &phys_device = phys_devices[i];
189 if (0 == physical_device_properties_map.count(phys_device)) {
190 auto phys_dev_props = new VkPhysicalDeviceProperties;
191 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
192 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600193
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700194 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
195 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700196 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700197 std::vector<VkExtensionProperties> ext_props{};
198 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
199 ext_props.resize(ext_count);
200 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
201 for (uint32_t j = 0; j < ext_count; j++) {
202 dev_exts_enumerated.insert(ext_props[j].extensionName);
203 }
204 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600205 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700206 }
207}
208
209void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
210 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
211 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
212 return;
213 }
214
215 if (pPhysicalDeviceCount && pPhysicalDevices) {
216 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
217 }
218}
219
220void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
221 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
222 VkResult result) {
223 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
224 return;
225 }
226
227 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
228 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
229 const auto &group = pPhysicalDeviceGroupProperties[i];
230 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
231 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600232 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700233}
234
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600235void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
236 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
237 delete (it->second);
238 it = physical_device_properties_map.erase(it);
239 }
240};
241
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700242void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700243 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700244 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700245 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700246 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
247 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700249 // Parmeter validation also uses extension data
250 stateless_validation->device_extensions = this->device_extensions;
251
252 VkPhysicalDeviceProperties device_properties = {};
253 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600254 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700255 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
256
sfricke-samsung45996a42021-09-16 13:45:27 -0700257 if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700258 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700259 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
260 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600261 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700262 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
263 }
264
sfricke-samsung45996a42021-09-16 13:45:27 -0700265 if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700266 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700267 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
268 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600269 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700270 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
271 }
272
sfricke-samsung45996a42021-09-16 13:45:27 -0700273 if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) {
Jason Macnak5c954952019-07-09 15:46:12 -0700274 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700275 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
276 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700277 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500278 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
279 }
280
sfricke-samsung45996a42021-09-16 13:45:27 -0700281 if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500282 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700283 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
284 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500285 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
286 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700287 }
288
sfricke-samsung45996a42021-09-16 13:45:27 -0700289 if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) {
sourav parmarcd5fb182020-07-17 12:58:44 -0700290 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700291 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
292 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700293 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
294 phys_dev_ext_props.acc_structure_props = acc_structure_props;
295 }
296
sfricke-samsung45996a42021-09-16 13:45:27 -0700297 if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) {
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700298 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700299 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
300 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700301 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
302 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
303 }
304
sfricke-samsung45996a42021-09-16 13:45:27 -0700305 if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) {
Piers Daniellcb6d8032021-04-19 18:51:26 -0600306 // Get the needed vertex attribute divisor limits
307 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
308 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
309 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
310 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
311 }
312
sfricke-samsung45996a42021-09-16 13:45:27 -0700313 if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) {
Piers Daniella7f93b62021-11-20 12:32:04 -0700314 // Get the needed blend operation advanced properties
ziga-lunarga283d022021-08-04 18:35:23 +0200315 auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>();
316 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props);
317 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
318 phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props;
319 }
320
Piers Daniella7f93b62021-11-20 12:32:04 -0700321 if (IsExtEnabled(device_extensions.vk_khr_maintenance4)) {
322 // Get the needed maintenance4 properties
323 auto maintance4_props = LvlInitStruct<VkPhysicalDeviceMaintenance4PropertiesKHR>();
324 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&maintance4_props);
325 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
326 phys_dev_ext_props.maintenance4_props = maintance4_props;
327 }
328
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800329 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700331 // Save app-enabled features in this device's validation object
332 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700333 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200334 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
335 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
336 if (features2) {
337 tmp_features2_state.features = features2->features;
338 } else if (pCreateInfo->pEnabledFeatures) {
339 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700340 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200341 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700342 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200343 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700344 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200345 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700346}
347
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700348bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500349 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600350 bool skip = false;
351
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200352 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
353 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
354 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600355 }
356
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700357 // If this device supports VK_KHR_portability_subset, it must be enabled
358 const std::string portability_extension_name("VK_KHR_portability_subset");
359 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
360 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
361 bool portability_requested = false;
362
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200363 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
364 skip |=
365 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
366 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
367 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
368 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700369 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
370 portability_requested = true;
371 }
372 }
373
374 if (portability_supported && !portability_requested) {
375 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
376 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
377 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600378 }
379
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200380 {
aitor-lunargd5301592022-01-05 22:38:16 +0100381 bool maint1 = IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME));
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700382 bool negative_viewport =
aitor-lunargd5301592022-01-05 22:38:16 +0100383 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
384 if (negative_viewport) {
385 // Only need to check for VK_KHR_MAINTENANCE_1_EXTENSION_NAME if api version is 1.0, otherwise it's deprecated due to
386 // integration into api version 1.1
387 if (api_version >= VK_API_VERSION_1_1) {
388 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-01840",
389 "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not include "
390 "VK_AMD_negative_viewport_height if api version is greater than or equal to 1.1.");
391 } else if (maint1) {
392 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
393 "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include "
394 "VK_KHR_maintenance1 and VK_AMD_negative_viewport_height.");
395 }
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200396 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600397 }
398
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600399 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200400 bool khr_bda =
401 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
402 bool ext_bda =
403 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600404 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700405 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
406 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
407 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600408 }
409 }
410
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600411 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
412 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700413 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600414 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800415 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700416 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800417 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700418 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600419 }
420 }
421
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700422 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500423 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700424 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500425 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
426 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
427 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
428 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700429 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700430 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
431 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
432 skip |= LogError(
433 device,
434 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
435 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
436 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700437 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700438 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -0700439 if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) {
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600440 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
441 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
442 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600443 }
444
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700445 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700446 if (vulkan_11_features) {
447 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
448 while (current) {
449 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
450 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
451 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
452 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
453 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
454 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700455 skip |= LogError(
456 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700457 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
458 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
459 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
460 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
461 break;
462 }
463 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
464 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800465
466 // Check features are enabled if matching extension is passed in as well
467 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
468 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
469 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
470 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
471 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800472 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-04476",
sfricke-samsungebda6792021-01-16 08:57:52 -0800473 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
474 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
475 }
476 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700477 }
478
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700479 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700480 if (vulkan_12_features) {
481 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
482 while (current) {
483 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
484 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
485 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
486 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
487 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
488 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
489 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
490 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
491 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
492 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
493 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
494 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
495 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700496 skip |= LogError(
497 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700498 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
499 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
500 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
501 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
502 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
503 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
504 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
505 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
506 break;
507 }
508 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
509 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700510 // Check features are enabled if matching extension is passed in as well
511 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
512 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
513 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
514 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
515 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800516 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02831",
sfricke-samsungabab4632020-05-04 06:51:46 -0700517 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
518 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
519 }
520 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
521 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
Mike Schuchardt9969d022021-12-20 15:51:55 -0800522 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02832",
sfricke-samsungabab4632020-05-04 06:51:46 -0700523 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
524 "is not VK_TRUE.",
525 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
526 }
527 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
528 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
529 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800530 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02833",
sfricke-samsungabab4632020-05-04 06:51:46 -0700531 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
532 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
533 }
534 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
535 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
536 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800537 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02834",
sfricke-samsungabab4632020-05-04 06:51:46 -0700538 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
539 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
540 }
541 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
542 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
543 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
544 skip |=
Mike Schuchardt9969d022021-12-20 15:51:55 -0800545 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02835",
sfricke-samsungabab4632020-05-04 06:51:46 -0700546 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
547 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
548 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
549 }
550 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200551 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
552 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
553 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
554 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
555 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
556 }
557 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700558 }
559
Tony-LunarG273f32f2021-09-28 08:56:30 -0600560 const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(pCreateInfo->pNext);
561 if (vulkan_13_features) {
562 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
563 while (current) {
564 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES ||
565 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES ||
566 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES ||
567 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES ||
568 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES ||
569 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES ||
570 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES ||
571 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES ||
572 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES ||
573 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES ||
574 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES ||
575 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES ||
576 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES) {
577 skip |= LogError(
578 instance, "VUID-VkDeviceCreateInfo-pNext-06532",
579 "If the pNext chain includes a VkPhysicalDeviceVulkan13Features structure, then it must not include a "
580 "VkPhysicalDeviceDynamicRenderingFeatures, VkPhysicalDeviceImageRobustnessFeatures, "
581 "VkPhysicalDeviceInlineUniformBlockFeatures, VkPhysicalDeviceMaintenance4Features, "
582 "VkPhysicalDevicePipelineCreationCacheControlFeatures, VkPhysicalDevicePrivateDataFeatures, "
583 "VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures, VkPhysicalDeviceShaderIntegerDotProductFeatures, "
584 "VkPhysicalDeviceShaderTerminateInvocationFeatures, VkPhysicalDeviceSubgroupSizeControlFeatures, "
585 "VkPhysicalDeviceSynchronization2Features, VkPhysicalDeviceTextureCompressionASTCHDRFeatures, or "
586 "VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures structure");
587 break;
588 }
589 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
590 }
591 }
592
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600593 // Validate pCreateInfo->pQueueCreateInfos
594 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600595
596 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700597 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
598 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600599 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700600 skip |=
601 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
602 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
603 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
604 "index value.",
605 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600606 }
607
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700608 if (queue_create_info.pQueuePriorities != nullptr) {
609 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
610 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600611 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700612 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
613 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
614 "] (=%f) is not between 0 and 1 (inclusive).",
615 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600616 }
617 }
618 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700619
620 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700621 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700622 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700623 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700624 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700625 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700626 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700627 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700628 }
Mike Schuchardta9101d32021-11-12 12:24:08 -0800629 if (((queue_create_info.flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) != 0) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700630 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
Mike Schuchardta9101d32021-11-12 12:24:08 -0800631 "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
632 "protectedMemory feature being enabled as well.");
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700633 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600634 }
635 }
636
sfricke-samsung30a57412020-05-15 21:14:54 -0700637 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700638 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700639 VkBool32 variable_pointers = VK_FALSE;
640 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700641 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700642 variable_pointers = vulkan_11_features->variablePointers;
643 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700644 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700645 variable_pointers = variable_pointers_features->variablePointers;
646 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700647 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700648 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700649 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
650 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
651 }
652
sfricke-samsungfd76c342020-05-29 23:13:43 -0700653 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700654 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700655 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700656 VkBool32 multiview_geometry_shader = VK_FALSE;
657 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700658 if (vulkan_11_features) {
659 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700660 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
661 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700662 } else if (multiview_features) {
663 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700664 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
665 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700666 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700667 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700668 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
669 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
670 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700671 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700672 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
673 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
674 }
675
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600676 return skip;
677}
678
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500679bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700680 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700681 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
682 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
683 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600684 }
685
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700686 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600687}
688
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700689bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500690 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100691 bool skip = false;
692
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600693 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700694 skip |=
695 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600696
697 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
698 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
699 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
700 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
702 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
703 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600704 }
705
706 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
707 // queueFamilyIndexCount uint32_t values
708 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
710 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
711 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
712 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600713 }
714 }
715
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700716 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
717 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
718 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
719 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
720 }
721
722 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
723 skip |=
724 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
725 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
726 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
727 }
728
729 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
730 skip |=
731 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
732 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
733 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
734 }
735
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600736 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
737 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
738 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
739 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
741 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
742 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600743 }
Piers Daniella7f93b62021-11-20 12:32:04 -0700744
745 const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(device_createinfo_pnext);
746 if (maintenance4_features && maintenance4_features->maintenance4) {
747 if (pCreateInfo->size > phys_dev_ext_props.maintenance4_props.maxBufferSize) {
748 skip |= LogError(device, "VUID-VkBufferCreateInfo-size-06409",
749 "vkCreateBuffer: pCreateInfo->size is larger than the maximum allowed buffer size "
750 "VkPhysicalDeviceMaintenance4Properties.maxBufferSize");
751 }
752 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 }
754
755 return skip;
756}
757
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700758bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500759 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600760 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600761
762 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800763 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700764 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600765 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
766 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
767 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
768 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700769 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
770 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
771 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600772 }
773
774 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
775 // queueFamilyIndexCount uint32_t values
776 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700777 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
778 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
779 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
780 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600781 }
782 }
783
Dave Houlton413a6782018-05-22 13:01:54 -0600784 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700785 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600786 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700787 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600788 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700789 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600790
Dave Houlton413a6782018-05-22 13:01:54 -0600791 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700792 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600793 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700794 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600795
Dave Houlton130c0212018-01-29 13:39:56 -0700796 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700797 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
798 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700799 skip |= LogError(
800 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600801 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
802 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700803 }
804
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600805 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100806 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
807 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700808 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
809 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
810 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600811 }
812
813 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700814 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100815 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700816 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
817 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
818 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
819 ") are not equal.",
820 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100821 }
822
823 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700824 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
825 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
826 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
827 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100828 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600829 }
830
831 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700832 skip |= LogError(
833 device, "VUID-VkImageCreateInfo-imageType-00957",
834 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600835 }
836 }
837
Dave Houlton130c0212018-01-29 13:39:56 -0700838 // 3D image may have only 1 layer
839 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700840 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
841 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700842 }
843
Dave Houlton130c0212018-01-29 13:39:56 -0700844 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
845 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
846 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
847 // At least one of the legal attachment bits must be set
848 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700849 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
850 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700851 }
852 // No flags other than the legal attachment bits may be set
853 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
854 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700855 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
856 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700857 }
858 }
859
Jeff Bolzef40fec2018-09-01 22:04:34 -0500860 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700861 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500862 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700863 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700864 ? static_cast<uint32_t>(ceil(log2(max_dim)))
865 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
866 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600867 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
869 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
870 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600871 }
872
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700873 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700874 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
875 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
876 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600877 }
878
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700879 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700880 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
881 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
882 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100883 }
884
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700885 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700886 skip |= LogError(
887 device, "VUID-VkImageCreateInfo-flags-01924",
888 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
889 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
890 }
891
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600892 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
893 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700894 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
895 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700896 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
897 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
898 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600899 }
900
901 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700902 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600903 // Linear tiling is unsupported
904 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700905 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700906 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
907 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600908 }
909
910 // Sparse 1D image isn't valid
911 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700912 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
913 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600914 }
915
916 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700917 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700918 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
919 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
920 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600921 }
922
923 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700924 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700925 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
926 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
927 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600928 }
929
930 // Multi-sample 2D image when device doesn't support it
931 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700932 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600933 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700934 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
935 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
936 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700937 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600938 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700939 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
940 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
941 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700942 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600943 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700944 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
945 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
946 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700947 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600948 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700949 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
950 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
951 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600952 }
953 }
954 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500955
Jeff Bolz9af91c52018-09-01 21:53:57 -0500956 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
957 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700958 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
959 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
960 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500961 }
962 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700963 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
964 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
965 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500966 }
967 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700968 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
969 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
970 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500971 }
972 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500973
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700974 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600975 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700976 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
977 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
978 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500979 }
980
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700981 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700982 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
983 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800984 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
985 "depth/stencil format.",
986 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500987 }
988
Dave Houlton142c4cb2018-10-17 15:04:41 -0600989 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700990 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
991 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
992 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
993 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500994 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600995 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700996 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
997 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
998 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
999 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -05001000 }
1001 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05001002
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001003 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -08001004 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -07001005 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
1006 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -08001007 "format (%s) must be a depth or depth/stencil format.",
1008 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -07001009 }
1010
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001011 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001012 if (image_stencil_struct != nullptr) {
1013 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
1014 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
1015 // No flags other than the legal attachment bits may be set
1016 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
1017 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001018 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
1019 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
1020 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
1021 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001022 }
1023 }
1024
sfricke-samsung61a57c02021-01-10 21:35:12 -08001025 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -05001026 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
1027 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001028 skip |=
1029 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
1030 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1031 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32
1032 ") exceeds device "
1033 "maxFramebufferWidth (%" PRIu32 ")",
1034 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001035 }
1036
1037 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001038 skip |=
1039 LogError(device, "VUID-VkImageCreateInfo-format-02537",
1040 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1041 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32
1042 ") exceeds device "
1043 "maxFramebufferHeight (%" PRIu32 ")",
1044 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001045 }
1046 }
1047
1048 if (!physical_device_features.shaderStorageImageMultisample &&
1049 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1050 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1051 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001052 LogError(device, "VUID-VkImageCreateInfo-format-02538",
1053 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1054 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
1055 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001056 }
1057
1058 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
1059 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001060 skip |= LogError(
1061 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001062 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1063 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1064 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1065 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1066 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001067 skip |= LogError(
1068 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001069 "vkCreateImage(): Depth-stencil image in which usage does not include "
1070 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1071 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1072 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1073 }
1074
1075 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1076 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001077 skip |= LogError(
1078 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001079 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1080 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1081 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1082 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1083 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001084 skip |= LogError(
1085 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001086 "vkCreateImage(): Depth-stencil image in which usage does not include "
1087 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1088 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1089 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1090 }
1091 }
1092 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001093
1094 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1095 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1096 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1097 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1098 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1099 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001100
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001101 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001102 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001103 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1104 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001105 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1106 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1107 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1108 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1109 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1110 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1111 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001112 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001113 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1114 } else if (drm_format_mod_list != nullptr) {
1115 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1116 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1117 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001118 }
1119 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1120 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1121 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1122 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1123 "in the pNext chain");
1124 }
1125 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001126
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001127 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001128 bool image_create_maybe_linear = false;
1129 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1130 image_create_maybe_linear = true;
1131 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1132 image_create_maybe_linear = false;
1133 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1134 image_create_maybe_linear =
1135 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001136 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001137 }
1138
1139 // If multi-sample, validate type, usage, tiling and mip levels.
1140 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001141 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001142 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1143 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1144 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1145 }
1146
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001147 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001148 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1149 image_create_maybe_linear)) {
1150 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1151 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1152 }
1153
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001154 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1155 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1156 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1157 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1158 "imageType must be VK_IMAGE_TYPE_2D.");
1159 }
1160 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1161 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1162 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1163 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1164 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001165 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001166 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001167 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1168 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1169 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1170 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1171 }
1172 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1173 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1174 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1175 "imageType must be VK_IMAGE_TYPE_2D.");
1176 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001177 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001178 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1179 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1180 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1181 }
1182 if (pCreateInfo->mipLevels != 1) {
1183 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001184 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32
1185 ") must be 1.",
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001186 pCreateInfo->mipLevels);
1187 }
1188 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001189
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001190 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001191 if (swapchain_create_info != nullptr) {
1192 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1193 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1194 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1195 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1196 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1197 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1198
1199 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1200 // also implicitly forces the check above that extent.depth is 1
1201 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1202 string_VkImageType(pCreateInfo->imageType));
1203 }
1204 if (pCreateInfo->mipLevels != 1) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001205 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %" PRIu32 ".", base_message,
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001206 pCreateInfo->mipLevels);
1207 }
1208 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1209 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1210 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1211 }
1212 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1213 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1214 base_message, string_VkImageTiling(pCreateInfo->tiling));
1215 }
1216 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1217 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1218 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1219 }
1220 const VkImageCreateFlags valid_flags =
1221 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001222 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001223 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001224 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001225 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001226 }
1227 }
1228 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001229
1230 // If Chroma subsampled format ( _420_ or _422_ )
1231 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1232 skip |=
1233 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1234 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1235 ") must be a multiple of 2.",
1236 string_VkFormat(image_format), pCreateInfo->extent.width);
1237 }
1238 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1239 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1240 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1241 ") must be a multiple of 2.",
1242 string_VkFormat(image_format), pCreateInfo->extent.height);
1243 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001244
1245 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1246 if (format_list_info) {
1247 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1248 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1249 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1250 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001251 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.",
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001252 viewFormatCount);
1253 }
1254 // Check if viewFormatCount is not zero that it is all compatible
1255 for (uint32_t i = 0; i < viewFormatCount; i++) {
Mike Schuchardtb0608492022-04-05 18:52:48 -07001256 const bool class_compatible =
1257 FormatCompatibilityClass(format_list_info->pViewFormats[i]) == FormatCompatibilityClass(image_format);
1258 if (!class_compatible) {
1259 if (image_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) {
1260 const bool size_compatible =
1261 FormatIsCompressed(format_list_info->pViewFormats[i])
1262 ? false
1263 : FormatElementSize(format_list_info->pViewFormats[i]) == FormatElementSize(image_format);
1264 if (!size_compatible) {
1265 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722",
1266 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1267 "] (%s) and VkImageCreateInfo::format (%s) are not compatible or size-compatible.",
1268 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
1269 }
1270 } else {
1271 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722",
1272 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1273 "] (%s) and VkImageCreateInfo::format (%s) are not compatible.",
1274 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
1275 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001276 }
1277 }
1278 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001279 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001280
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001281 return skip;
1282}
1283
Jeff Bolz99e3f632020-03-24 22:59:22 -05001284bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1285 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1286 bool skip = false;
1287
1288 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001289 // Validate feature set if using CUBE_ARRAY
1290 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1291 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1292 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1293 "enabling the imageCubeArray feature.");
1294 }
1295
Jeff Bolz99e3f632020-03-24 22:59:22 -05001296 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1297 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1298 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001299 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1300 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001301 pCreateInfo->subresourceRange.layerCount);
1302 }
1303 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001304 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1305 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1306 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1307 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001308 }
1309 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001310
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001311 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001312 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001313 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1314 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1315 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1316 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1317 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1318 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1319 }
sfricke-samsunge3086292021-11-18 23:02:35 -08001320 if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) &&
1321 (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001322 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1323 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1324 "not an ASTC format.",
1325 string_VkFormat(pCreateInfo->format));
1326 }
1327 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001328
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001329 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001330 if (ycbcr_conversion != nullptr) {
1331 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1332 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1333 skip |= LogError(
1334 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1335 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1336 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1337 "r swizzle = %s\n"
1338 "g swizzle = %s\n"
1339 "b swizzle = %s\n"
1340 "a swizzle = %s\n",
1341 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1342 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1343 }
1344 }
1345 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001346 }
1347 return skip;
1348}
1349
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001350bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001351 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001352 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001353
1354 // Note: for numerical correctness
1355 // - float comparisons should expect NaN (comparison always false).
1356 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1357
1358 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001359 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001360 if (v1_f <= 0.0f) return true;
1361
1362 float intpart;
1363 const float fract = modff(v1_f, &intpart);
1364
1365 assert(std::numeric_limits<float>::radix == 2);
1366 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1367 if (intpart >= u32_max_plus1) return false;
1368
1369 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001370 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001371 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001372 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001373 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001374 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001375 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001376 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001377 };
1378
1379 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1380 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1381 return (v1_f <= v2_f);
1382 };
1383
1384 // width
1385 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001386 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001387
1388 if (!(viewport.width > 0.0f)) {
1389 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001390 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1391 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001392 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1393 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001394 skip |= LogError(object, "VUID-VkViewport-width-01771",
1395 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1396 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001397 }
1398
1399 // height
1400 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001401 const bool negative_height_enabled =
1402 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001403 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001404
1405 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1406 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001407 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1408 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001409 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1410 height_healthy = false;
1411
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001412 skip |= LogError(object, "VUID-VkViewport-height-01773",
1413 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1414 ").",
1415 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001416 }
1417
1418 // x
1419 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001420 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001421 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001422 skip |= LogError(object, "VUID-VkViewport-x-01774",
1423 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1424 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001425 }
1426
1427 // x + width
1428 if (x_healthy && width_healthy) {
1429 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001430 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001431 skip |= LogError(
1432 object, "VUID-VkViewport-x-01232",
1433 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1434 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1435 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001436 }
1437 }
1438
1439 // y
1440 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001441 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001442 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001443 skip |= LogError(object, "VUID-VkViewport-y-01775",
1444 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1445 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001446 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001447 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001448 skip |= LogError(object, "VUID-VkViewport-y-01776",
1449 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1450 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001451 }
1452
1453 // y + height
1454 if (y_healthy && height_healthy) {
1455 const float boundary = viewport.y + viewport.height;
1456
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001457 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001458 skip |= LogError(object, "VUID-VkViewport-y-01233",
1459 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1460 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1461 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001462 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001463 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001464 LogError(object, "VUID-VkViewport-y-01777",
1465 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1466 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1467 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001468 }
1469 }
1470
sfricke-samsungfd06d422021-01-22 02:17:21 -08001471 // 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 -07001472 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001473 // minDepth
1474 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001475 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001476 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001477 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1478 "[0.0, 1.0] range.",
1479 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001480 }
1481
1482 // maxDepth
1483 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001484 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001485 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001486 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1487 "[0.0, 1.0] range.",
1488 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001489 }
1490 }
1491
1492 return skip;
1493}
1494
Dave Houlton142c4cb2018-10-17 15:04:41 -06001495struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001496 VkShadingRatePaletteEntryNV shadingRate;
1497 uint32_t width;
1498 uint32_t height;
1499};
1500
1501// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001502static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001503 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1504 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1505 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1506 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1507 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1508 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001509};
1510
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001511bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001512 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001513
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001514 SampleOrderInfo *sample_order_info;
1515 uint32_t info_idx = 0;
1516 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1517 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1518 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001519 break;
1520 }
1521 }
1522
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001523 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001524 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1525 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1526 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001527 return skip;
1528 }
1529
Dave Houlton142c4cb2018-10-17 15:04:41 -06001530 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001531 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001532 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1533 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1534 ") must "
1535 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1536 "is set in framebufferNoAttachmentsSampleCounts.",
1537 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001538 }
1539
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001540 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001541 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1542 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1543 ") must "
1544 "be equal to the product of sampleCount (=%" PRIu32
1545 "), the fragment width for shadingRate "
1546 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001547 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001548 }
1549
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001550 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001551 skip |= LogError(
1552 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001553 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1554 ") must "
1555 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001556 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001557 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001558
1559 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001560 // the first width*height*sampleCount bits to all be set. Note: There is no
1561 // guarantee that 64 bits is enough, but practically it's unlikely for an
1562 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001563 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001564 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001565 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001566 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1567 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001568 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1569 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001570 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001571 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001572 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1573 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001574 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001575 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001576 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1577 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001578 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001579 uint32_t idx =
1580 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1581 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001582 }
1583
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001584 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1585 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001586 skip |= LogError(
1587 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001588 "The array pSampleLocations must contain exactly one entry for "
1589 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001590 }
1591
1592 return skip;
1593}
1594
sfricke-samsung51303fb2021-05-09 19:09:13 -07001595bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1596 const VkAllocationCallbacks *pAllocator,
1597 VkPipelineLayout *pPipelineLayout) const {
1598 bool skip = false;
1599 // Validate layout count against device physical limit
1600 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1601 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001602 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1603 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001604 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1605 }
1606
1607 // Validate Push Constant ranges
1608 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1609 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1610 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1611 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1612 // Check that offset + size don't exceed the max.
1613 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1614 if (offset >= max_push_constants_size) {
1615 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001616 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1617 ") that exceeds this "
1618 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001619 i, offset, max_push_constants_size);
1620 }
1621 if (size > max_push_constants_size - offset) {
1622 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001623 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1624 ") and size (%" PRIu32
1625 ") "
1626 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001627 i, offset, size, max_push_constants_size);
1628 }
1629
1630 // size needs to be non-zero and a multiple of 4.
1631 if (size == 0) {
1632 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001633 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1634 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001635 i, size);
1636 }
1637 if (size & 0x3) {
1638 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001639 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1640 ") is not a multiple of 4.",
1641 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001642 }
1643
1644 // offset needs to be a multiple of 4.
1645 if ((offset & 0x3) != 0) {
1646 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001647 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1648 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001649 i, offset);
1650 }
1651 }
1652
1653 // 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.
1654 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1655 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1656 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001657 skip |=
1658 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1659 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001660 }
1661 }
1662 }
1663 return skip;
1664}
1665
ziga-lunargc6341372021-07-28 12:57:42 +02001666bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1667 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1668 bool skip = false;
1669
1670 const auto *required_subgroup_size_features =
1671 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1672
1673 if (required_subgroup_size_features) {
1674 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1675 skip |= LogError(
1676 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1677 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1678 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1679 func_name, msg, pCreateInfo->flags);
1680 }
1681 }
1682
1683 return skip;
1684}
1685
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001686bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1687 uint32_t createInfoCount,
1688 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1689 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001690 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001691 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001692
1693 if (pCreateInfos != nullptr) {
1694 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001695 bool has_dynamic_viewport = false;
1696 bool has_dynamic_scissor = false;
1697 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001698 bool has_dynamic_depth_bias = false;
1699 bool has_dynamic_blend_constant = false;
1700 bool has_dynamic_depth_bounds = false;
1701 bool has_dynamic_stencil_compare = false;
1702 bool has_dynamic_stencil_write = false;
1703 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001704 bool has_dynamic_viewport_w_scaling_nv = false;
1705 bool has_dynamic_discard_rectangle_ext = false;
1706 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001707 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001708 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001709 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001710 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001711 bool has_dynamic_cull_mode = false;
1712 bool has_dynamic_front_face = false;
1713 bool has_dynamic_primitive_topology = false;
1714 bool has_dynamic_viewport_with_count = false;
1715 bool has_dynamic_scissor_with_count = false;
1716 bool has_dynamic_vertex_input_binding_stride = false;
1717 bool has_dynamic_depth_test_enable = false;
1718 bool has_dynamic_depth_write_enable = false;
1719 bool has_dynamic_depth_compare_op = false;
1720 bool has_dynamic_depth_bounds_test_enable = false;
1721 bool has_dynamic_stencil_test_enable = false;
1722 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001723 bool has_patch_control_points = false;
1724 bool has_rasterizer_discard_enable = false;
1725 bool has_depth_bias_enable = false;
1726 bool has_logic_op = false;
1727 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001728 bool has_dynamic_vertex_input = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001729
1730 // Create a copy of create_info and set non-included sub-state to null
1731 auto create_info = pCreateInfos[i];
1732 const auto *graphics_lib_info = LvlFindInChain<VkGraphicsPipelineLibraryCreateInfoEXT>(create_info.pNext);
1733 if (graphics_lib_info) {
1734 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT)) {
1735 create_info.pVertexInputState = nullptr;
1736 create_info.pInputAssemblyState = nullptr;
1737 }
1738 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT)) {
1739 create_info.pViewportState = nullptr;
1740 create_info.pRasterizationState = nullptr;
1741 create_info.pTessellationState = nullptr;
1742 }
1743 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT)) {
1744 create_info.pDepthStencilState = nullptr;
1745 }
1746 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) {
1747 create_info.pColorBlendState = nullptr;
1748 }
1749 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1750 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1751 create_info.pMultisampleState = nullptr;
1752 }
1753 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1754 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT))) {
1755 create_info.layout = VK_NULL_HANDLE;
1756 }
1757 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1758 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1759 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1760 create_info.renderPass = VK_NULL_HANDLE;
1761 create_info.subpass = 0;
1762 }
1763 }
1764
1765 // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline"
1766 if (create_info.pDynamicState != nullptr) {
1767 const auto &dynamic_state_info = *create_info.pDynamicState;
Petr Kraus299ba622017-11-24 03:09:03 +01001768 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1769 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001770 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1771 if (has_dynamic_viewport == true) {
1772 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1773 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001774 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001775 i);
1776 }
1777 has_dynamic_viewport = true;
1778 }
1779 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1780 if (has_dynamic_scissor == true) {
1781 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1782 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001783 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001784 i);
1785 }
1786 has_dynamic_scissor = true;
1787 }
1788 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1789 if (has_dynamic_line_width == true) {
1790 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1791 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001792 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001793 i);
1794 }
1795 has_dynamic_line_width = true;
1796 }
1797 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1798 if (has_dynamic_depth_bias == true) {
1799 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1800 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001801 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001802 i);
1803 }
1804 has_dynamic_depth_bias = true;
1805 }
1806 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1807 if (has_dynamic_blend_constant == true) {
1808 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1809 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001810 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001811 i);
1812 }
1813 has_dynamic_blend_constant = true;
1814 }
1815 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1816 if (has_dynamic_depth_bounds == true) {
1817 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1818 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001819 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001820 i);
1821 }
1822 has_dynamic_depth_bounds = true;
1823 }
1824 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1825 if (has_dynamic_stencil_compare == true) {
1826 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1827 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001828 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001829 i);
1830 }
1831 has_dynamic_stencil_compare = true;
1832 }
1833 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1834 if (has_dynamic_stencil_write == true) {
1835 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1836 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001837 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001838 i);
1839 }
1840 has_dynamic_stencil_write = true;
1841 }
1842 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1843 if (has_dynamic_stencil_reference == true) {
1844 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1845 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001846 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001847 i);
1848 }
1849 has_dynamic_stencil_reference = true;
1850 }
1851 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1852 if (has_dynamic_viewport_w_scaling_nv == true) {
1853 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1854 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001855 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001856 i);
1857 }
1858 has_dynamic_viewport_w_scaling_nv = true;
1859 }
1860 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1861 if (has_dynamic_discard_rectangle_ext == true) {
1862 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1863 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001864 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001865 i);
1866 }
1867 has_dynamic_discard_rectangle_ext = true;
1868 }
1869 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1870 if (has_dynamic_sample_locations_ext == true) {
1871 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1872 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001873 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001874 i);
1875 }
1876 has_dynamic_sample_locations_ext = true;
1877 }
1878 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1879 if (has_dynamic_exclusive_scissor_nv == true) {
1880 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1881 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001882 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001883 i);
1884 }
1885 has_dynamic_exclusive_scissor_nv = true;
1886 }
1887 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1888 if (has_dynamic_shading_rate_palette_nv == true) {
1889 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1890 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001891 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001892 i);
1893 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001894 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001895 }
1896 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1897 if (has_dynamic_viewport_course_sample_order_nv == true) {
1898 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1899 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001900 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001901 i);
1902 }
1903 has_dynamic_viewport_course_sample_order_nv = true;
1904 }
1905 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1906 if (has_dynamic_line_stipple == true) {
1907 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1908 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001909 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001910 i);
1911 }
1912 has_dynamic_line_stipple = true;
1913 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001914 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1915 if (has_dynamic_cull_mode) {
1916 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1917 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001918 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001919 i);
1920 }
1921 has_dynamic_cull_mode = true;
1922 }
1923 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1924 if (has_dynamic_front_face) {
1925 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1926 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001927 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001928 i);
1929 }
1930 has_dynamic_front_face = true;
1931 }
1932 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1933 if (has_dynamic_primitive_topology) {
1934 skip |= LogError(
1935 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1936 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001937 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001938 i);
1939 }
1940 has_dynamic_primitive_topology = true;
1941 }
1942 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1943 if (has_dynamic_viewport_with_count) {
1944 skip |= LogError(
1945 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1946 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001947 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001948 i);
1949 }
1950 has_dynamic_viewport_with_count = true;
1951 }
1952 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1953 if (has_dynamic_scissor_with_count) {
1954 skip |= LogError(
1955 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1956 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001957 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001958 i);
1959 }
1960 has_dynamic_scissor_with_count = true;
1961 }
1962 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1963 if (has_dynamic_vertex_input_binding_stride) {
1964 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1965 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1966 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001967 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001968 i);
1969 }
1970 has_dynamic_vertex_input_binding_stride = true;
1971 }
1972 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1973 if (has_dynamic_depth_test_enable) {
1974 skip |= LogError(
1975 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1976 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001977 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001978 i);
1979 }
1980 has_dynamic_depth_test_enable = true;
1981 }
1982 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1983 if (has_dynamic_depth_write_enable) {
1984 skip |= LogError(
1985 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1986 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001987 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001988 i);
1989 }
1990 has_dynamic_depth_write_enable = true;
1991 }
1992 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1993 if (has_dynamic_depth_compare_op) {
1994 skip |=
1995 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1996 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001997 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001998 i);
1999 }
2000 has_dynamic_depth_compare_op = true;
2001 }
2002 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
2003 if (has_dynamic_depth_bounds_test_enable) {
2004 skip |= LogError(
2005 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2006 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002007 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002008 i);
2009 }
2010 has_dynamic_depth_bounds_test_enable = true;
2011 }
2012 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
2013 if (has_dynamic_stencil_test_enable) {
2014 skip |= LogError(
2015 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2016 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002017 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002018 i);
2019 }
2020 has_dynamic_stencil_test_enable = true;
2021 }
2022 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
2023 if (has_dynamic_stencil_op) {
2024 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2025 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002026 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002027 i);
2028 }
2029 has_dynamic_stencil_op = true;
2030 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002031 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
2032 // Not allowed for graphics pipelines
2033 skip |= LogError(
2034 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
2035 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002036 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
2037 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002038 i, state_index);
2039 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002040 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
2041 if (has_patch_control_points) {
2042 skip |= LogError(
2043 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2044 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002045 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002046 i);
2047 }
2048 has_patch_control_points = true;
2049 }
2050 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2051 if (has_rasterizer_discard_enable) {
2052 skip |= LogError(
2053 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2054 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002055 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002056 i);
2057 }
2058 has_rasterizer_discard_enable = true;
2059 }
2060 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2061 if (has_depth_bias_enable) {
2062 skip |= LogError(
2063 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2064 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002065 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002066 i);
2067 }
2068 has_depth_bias_enable = true;
2069 }
2070 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2071 if (has_logic_op) {
2072 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2073 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002074 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002075 i);
2076 }
2077 has_logic_op = true;
2078 }
2079 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2080 if (has_primitive_restart_enable) {
2081 skip |= LogError(
2082 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2083 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002084 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002085 i);
2086 }
2087 has_primitive_restart_enable = true;
2088 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002089 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2090 if (has_dynamic_vertex_input) {
2091 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002092 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2093 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2094 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002095 }
2096 has_dynamic_vertex_input = true;
2097 }
Petr Kraus299ba622017-11-24 03:09:03 +01002098 }
2099 }
2100
sfricke-samsung3b944422021-01-23 02:15:19 -08002101 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2102 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2103 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002104 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2105 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002106 i);
2107 }
2108
2109 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2110 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2111 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002112 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002113 i);
2114 }
2115
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002116 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext);
2117 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) {
Tony-LunarGce3244a2021-11-19 12:33:40 -07002118 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02668",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002119 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2120 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2121 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002122 i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002123 }
2124
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002125 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002126
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002127 // Collect active stages and other information
2128 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002129 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002130 bool has_eval = false;
2131 bool has_control = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002132 if (create_info.pStages != nullptr) {
2133 for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) {
2134 active_shaders |= create_info.pStages[stage_index].stage;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002135
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002136 if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002137 has_control = true;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002138 } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002139 has_eval = true;
2140 }
2141
2142 skip |= validate_string(
2143 "vkCreateGraphicsPipelines",
2144 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002145 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", create_info.pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002146
2147 std::stringstream msg;
2148 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2149 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002150 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002151 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002152 }
2153
2154 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002155 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2156 skip |=
2157 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2158 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2159 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2160 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002161
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002162 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002163 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2164
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002165 skip |= validate_struct_pnext(
2166 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002167 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002168 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2169 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2170 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2171 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002172
2173 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002174 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002175 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2176 }
2177
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002178 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002179 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2180 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002181 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002182 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2183 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2184
2185 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002186 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002187 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002188
2189 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002190 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002191 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2192
2193 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2194 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002195 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002196 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2197
2198 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002199 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002200 }
2201
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002202 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2203 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002204
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002205 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002206 skip |=
2207 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2208 "vkCreateGraphicsPipelines: pararameter "
2209 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2210 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002211 }
2212
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002213 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002214 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002215 skip |=
2216 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2217 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2218 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2219 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2220 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002221 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2222 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002223 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002224 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2225 skip |=
2226 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2227 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002228 create_info.pVertexInputState->vertexBindingDescriptionCount,
2229 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002230 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2231
2232 skip |= validate_array(
2233 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2234 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2235 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2236 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2237
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002238 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002239 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002240 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002241 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002242 skip |= validate_ranged_enum(
2243 "vkCreateGraphicsPipelines",
2244 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2245 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002246 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002247 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2248 }
2249 }
2250
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002251 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002252 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002253 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002254 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002255 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002256 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002257 skip |= validate_ranged_enum(
2258 "vkCreateGraphicsPipelines",
2259 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2260 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002261 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002262 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002263 if (FormatIsDepthOrStencil(format)) {
2264 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2265 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2266 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2267 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002268 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2269 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002270 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2271 "alignment, replace with a color format.",
2272 i, vertex_attribute_description_index, string_VkFormat(format));
2273 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002274 }
2275 }
2276
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002277 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002278 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2279 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002280 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2281 ") is "
2282 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002283 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002284 }
2285
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002286 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002287 skip |=
2288 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2289 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002290 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2291 ") is "
2292 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002293 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002294 }
2295
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002296 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002297 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2298 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002299 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2300 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002301 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2302 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002303 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2304 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002305 "(%" PRIu32 ") is not distinct.",
2306 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002307 }
2308 vertex_bindings.insert(vertex_bind_desc.binding);
2309
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002310 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002311 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2312 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002313 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2314 "].binding (%" PRIu32
2315 ") is "
2316 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002317 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002318 }
2319
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002320 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002321 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2322 "vkCreateGraphicsPipelines: parameter "
2323 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2324 "].stride (%" PRIu32
2325 ") is greater "
2326 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2327 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002328 }
2329 }
2330
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002331 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002332 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2333 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002334 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2335 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002336 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2337 "vkCreateGraphicsPipelines: parameter "
2338 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2339 "].location (%" PRIu32 ") is not distinct.",
2340 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002341 }
2342 attribute_locations.insert(vertex_attrib_desc.location);
2343
2344 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2345 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002346 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2347 "vkCreateGraphicsPipelines: parameter "
2348 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2349 "].binding (%" PRIu32
2350 ") does not exist "
2351 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2352 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002353 }
2354
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002355 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002356 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2357 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002358 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2359 "].location (%" PRIu32
2360 ") is "
2361 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002362 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002363 }
2364
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002365 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002366 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2367 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002368 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2369 "].binding (%" PRIu32
2370 ") is "
2371 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002372 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002373 }
2374
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002375 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002376 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2377 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002378 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2379 "].offset (%" PRIu32
2380 ") is "
2381 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002382 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002383 }
2384 }
2385 }
2386
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002387 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2388 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002389 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002390 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002391 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2392 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002393 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002394 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002395 i, i);
2396 } else {
2397 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2398 skip |= validate_struct_pnext(
2399 "vkCreateGraphicsPipelines",
2400 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002401 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002402 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2403 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002404
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002405 skip |= validate_reserved_flags(
2406 "vkCreateGraphicsPipelines",
2407 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002408 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002409
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002410 if (create_info.pTessellationState->patchControlPoints == 0 ||
2411 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2412 skip |=
2413 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2414 "vkCreateGraphicsPipelines: invalid parameter "
2415 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2416 ". patchControlPoints "
2417 "should be >0 and <=%" PRIu32 ".",
2418 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002419 }
2420 }
2421 }
2422
2423 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002424 if ((create_info.pRasterizationState != nullptr) &&
2425 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2426 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002427 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2428 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2429 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2430 "].pViewportState (=NULL) is not a valid pointer.",
2431 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002432 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002433 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002434
2435 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002436 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2437 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2438 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2439 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002440 }
2441
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002442 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002443 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002444 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2445 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002446 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2447 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002448 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002449 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002450 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002451 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002452 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002453 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002454 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002455 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002456 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002457 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002458 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002459 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002460
2461 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002462 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002463 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002464 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002465
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002466 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002467 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002468 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002469 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002470 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002471 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2472 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002473 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002474 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2475 const auto depth_clip_control_struct =
2476 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002477
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002478 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002479 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002480 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2481 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2482 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2483 ") is not 1.",
2484 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002485 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002486
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002487 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002488 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2489 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2490 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2491 ") is not 1.",
2492 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002493 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002494
Dave Houlton142c4cb2018-10-17 15:04:41 -06002495 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2496 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002497 skip |= LogError(
2498 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2499 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2500 "disabled, but pCreateInfos[%" PRIu32
2501 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2502 ") is not 1.",
2503 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002504 }
2505
Jeff Bolz9af91c52018-09-01 21:53:57 -05002506 if (shading_rate_image_struct &&
2507 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002508 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2509 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2510 "disabled, but pCreateInfos[%" PRIu32
2511 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2512 ") is neither 0 nor 1.",
2513 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002514 }
2515
Petr Krausa6103552017-11-16 21:21:58 +01002516 } else { // multiViewport enabled
2517 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002518 if (!has_dynamic_viewport_with_count) {
2519 skip |= LogError(
2520 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2521 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2522 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002523 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002524 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2525 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2526 "].pViewportState->viewportCount (=%" PRIu32
2527 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2528 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002529 } else if (has_dynamic_viewport_with_count) {
2530 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2531 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2532 "].pViewportState->viewportCount (=%" PRIu32
2533 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2534 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002535 }
Petr Krausa6103552017-11-16 21:21:58 +01002536
2537 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002538 if (!has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002539 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2540 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2541 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002542 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002543 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002544 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2545 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002546 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002547 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2548 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2549 "].pViewportState->scissorCount (=%" PRIu32
2550 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2551 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002552 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002553 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2554 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2555 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2556 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002557 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2558 "].pViewportState->scissorCount (=%" PRIu32
2559 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2560 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002561 }
2562 }
2563
ziga-lunarg845883b2021-07-14 15:05:00 +02002564 if (!has_dynamic_scissor && viewport_state.pScissors) {
2565 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2566 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002567
2568 if (scissor.offset.x < 0) {
2569 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2570 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2571 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2572 scissor.offset.x, i, scissor_i);
2573 }
2574
2575 if (scissor.offset.y < 0) {
2576 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2577 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2578 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2579 scissor.offset.y, i, scissor_i);
2580 }
2581
ziga-lunarg845883b2021-07-14 15:05:00 +02002582 const int64_t x_sum =
2583 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2584 if (x_sum > std::numeric_limits<int32_t>::max()) {
2585 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2586 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2587 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2588 "] will overflow int32_t.",
2589 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2590 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002591
ziga-lunarg845883b2021-07-14 15:05:00 +02002592 const int64_t y_sum =
2593 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2594 if (y_sum > std::numeric_limits<int32_t>::max()) {
2595 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2596 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2597 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2598 "] will overflow int32_t.",
2599 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2600 }
2601 }
2602 }
2603
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002604 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002605 skip |=
2606 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2607 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2608 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2609 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002610 }
2611
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002612 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002613 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2614 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2615 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2616 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2617 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002618 }
2619
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002620 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2621 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2622 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2623 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2624 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2625 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2626 skip |= LogError(
2627 device, vuid,
2628 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2629 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2630 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2631 }
Petr Krausa6103552017-11-16 21:21:58 +01002632 }
2633
Dave Houlton142c4cb2018-10-17 15:04:41 -06002634 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002635 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002636 skip |=
2637 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2638 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2639 ") must be zero or identical to pCreateInfos[%" PRIu32
2640 "].pViewportState->viewportCount (=%" PRIu32 ").",
2641 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002642 }
2643
Dave Houlton142c4cb2018-10-17 15:04:41 -06002644 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002645 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002646 skip |= LogError(
2647 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002648 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2649 "] "
2650 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2651 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2652 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002653 }
2654
Petr Krausa6103552017-11-16 21:21:58 +01002655 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002656 skip |= LogError(
2657 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002658 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2659 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002660 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2661 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002662 }
2663
2664 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002665 skip |= LogError(
2666 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002667 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2668 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002669 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2670 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002671 }
2672
Jeff Bolz3e71f782018-08-29 23:15:45 -05002673 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002674 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2675 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2676 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002677 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002678 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2679 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2680 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2681 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002682 }
2683
Jeff Bolz9af91c52018-09-01 21:53:57 -05002684 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002685 shading_rate_image_struct->viewportCount > 0 &&
2686 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002687 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002688 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002689 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002690 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2691 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002692 i, i);
2693 }
2694
Chris Mayer328d8212018-12-11 14:16:18 +01002695 if (vp_swizzle_struct) {
2696 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002697 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2698 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2699 " does "
2700 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2701 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002702 }
2703 }
2704
Petr Krausb3fcdb42018-01-09 22:09:09 +01002705 // validate the VkViewports
2706 if (!has_dynamic_viewport && viewport_state.pViewports) {
2707 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2708 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002709 const char *fn_name = "vkCreateGraphicsPipelines";
2710 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2711 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2712 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002713 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002714 }
2715 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002716
sfricke-samsung45996a42021-09-16 13:45:27 -07002717 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002718 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2719 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2720 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2721 "VK_NV_clip_space_w_scaling extension is not enabled.",
2722 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002723 }
2724
sfricke-samsung45996a42021-09-16 13:45:27 -07002725 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002726 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2727 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2728 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2729 "VK_EXT_discard_rectangles extension is not enabled.",
2730 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002731 }
2732
sfricke-samsung45996a42021-09-16 13:45:27 -07002733 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002734 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2735 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2736 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2737 "VK_EXT_sample_locations extension is not enabled.",
2738 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002739 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002740
sfricke-samsung45996a42021-09-16 13:45:27 -07002741 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002742 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2743 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2744 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2745 "VK_NV_scissor_exclusive extension is not enabled.",
2746 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002747 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002748
2749 if (coarse_sample_order_struct &&
2750 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2751 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002752 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2753 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2754 "] "
2755 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2756 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2757 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002758 }
2759
2760 if (coarse_sample_order_struct) {
2761 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002762 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002763 }
2764 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002765
2766 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2767 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002768 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2769 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2770 "] "
2771 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2772 ") "
2773 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2774 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002775 }
2776 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002777 skip |= LogError(
2778 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002779 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2780 "] "
2781 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2782 i);
2783 }
2784 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002785
2786 if (depth_clip_control_struct) {
2787 const auto *depth_clip_control_features =
2788 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2789 const bool enabled_depth_clip_control =
2790 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2791 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2792 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2793 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2794 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2795 "depthClipControl feature is not enabled. ",
2796 i);
2797 }
2798 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002799 }
2800
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002801 const bool is_frag_out_graphics_lib =
2802 graphics_lib_info &&
2803 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002804 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002805 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002806 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2807 "].pRasterizationState->rasterizerDiscardEnable "
2808 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002809 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002810 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002811 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002812 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002813 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2814 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002815 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002816 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002817 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002818
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002819 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002820 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002821 skip |= validate_struct_pnext(
2822 "vkCreateGraphicsPipelines",
2823 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002824 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002825 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2826 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002827
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002828 skip |= validate_reserved_flags(
2829 "vkCreateGraphicsPipelines",
2830 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002831 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002832
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002833 skip |= validate_bool32(
2834 "vkCreateGraphicsPipelines",
2835 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002836 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002837
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002838 skip |= validate_array(
2839 "vkCreateGraphicsPipelines",
2840 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2841 ParameterName::IndexVector{i}),
2842 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002843 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
2844 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002845
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002846 skip |= validate_flags("vkCreateGraphicsPipelines",
2847 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2848 ParameterName::IndexVector{i}),
2849 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002850 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002851 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002853 skip |= validate_bool32("vkCreateGraphicsPipelines",
2854 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
2855 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002856 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002857
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002858 skip |= validate_bool32(
2859 "vkCreateGraphicsPipelines",
2860 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002861 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002862
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002863 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002864 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
2865 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2866 "].pMultisampleState->sType must be "
2867 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002868 i);
John Zulauf7acac592017-11-06 11:15:53 -07002869 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002870 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002871 if (!physical_device_features.sampleRateShading) {
2872 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2873 "vkCreateGraphicsPipelines(): parameter "
2874 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
2875 i);
2876 }
2877 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2878 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002879 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002880 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002881
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002882 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2883 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2884 "].pMultisampleState->minSampleShading.",
2885 i);
2886 }
John Zulauf7acac592017-11-06 11:15:53 -07002887 }
2888 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002889
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002890 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002891 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002892
2893 if (line_state) {
2894 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2895 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002896 if (create_info.pMultisampleState->alphaToCoverageEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002897 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002898 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2899 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002900 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002901 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002902 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002903 if (create_info.pMultisampleState->alphaToOneEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002904 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002905 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2906 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002907 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002908 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002909 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002910 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002911 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002912 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2913 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002914 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002915 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002916 }
2917 }
2918 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2919 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2920 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002921 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002922 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
2923 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002924 "range [1,256].",
2925 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002926 }
2927 }
2928 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002929 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002930 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2931 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002932 skip |=
2933 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002934 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2935 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002936 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2937 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002938 }
2939 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2940 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002941 skip |=
2942 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002943 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2944 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002945 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2946 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002947 }
2948 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2949 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002950 skip |=
2951 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002952 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2953 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002954 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2955 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002956 }
2957 if (line_state->stippledLineEnable) {
2958 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2959 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002960 skip |=
2961 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002962 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2963 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002964 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2965 "stippledRectangularLines feature.",
2966 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002967 }
2968 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2969 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002970 skip |=
2971 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002972 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2973 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002974 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2975 "stippledBresenhamLines feature.",
2976 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002977 }
2978 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2979 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002980 skip |=
2981 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002982 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2983 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002984 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2985 "stippledSmoothLines feature.",
2986 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002987 }
2988 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05002989 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002990 skip |=
2991 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002992 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2993 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002994 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2995 "stippledRectangularLines and strictLines features.",
2996 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002997 }
2998 }
2999 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000 }
3001
Petr Krause91f7a12017-12-14 20:57:36 +01003002 bool uses_color_attachment = false;
3003 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003004 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003005 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003006 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003007 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003008 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003009 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003010 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003011 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003012 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003013 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003014 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003015 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003016 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01003017 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003018 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003019 }
3020
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003021 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003022 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003023 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003024 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003025 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003026 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003027
Mike Schuchardt00e81452021-11-29 11:11:20 -08003028 skip |=
3029 validate_flags("vkCreateGraphicsPipelines",
3030 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3031 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003032 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003033 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003034
3035 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003036 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003037 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003038 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003039
3040 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003041 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003042 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003043 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003044
3045 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003046 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003047 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003048 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003049 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003050
3051 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003052 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003053 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003054 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003055
3056 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003057 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003058 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003059 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003060
3061 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003062 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003063 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003064 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003065 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003066
3067 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003068 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003069 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003070 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003071 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003072
3073 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003074 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003075 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003076 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003077 "VUID-VkStencilOpState-depthFailOp-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].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003082 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003083 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003084
3085 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003086 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003087 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003088 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003089 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003090
3091 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003092 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003093 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003094 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003095 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003096
3097 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003098 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003099 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003100 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003101 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003102
3103 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003104 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003105 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003106 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003107 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003108
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003109 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003110 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003111 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3112 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003113 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3114 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003115 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003116
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003117 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003118 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3119 const auto *rasterization_order_attachment_access_feature =
3120 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3121 const bool rasterization_order_depth_attachment_access_feature_enabled =
3122 rasterization_order_attachment_access_feature &&
3123 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3124 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3125 skip |= LogError(
3126 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3127 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3128 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3129 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003130 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003131 }
3132
3133 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3134 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003135 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003136 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3137 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003138 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003139 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3140 }
3141 }
3142
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003143 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003144 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3145 const auto *rasterization_order_attachment_access_feature =
3146 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3147 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3148 rasterization_order_attachment_access_feature &&
3149 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3150 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3151 skip |= LogError(
3152 device,
3153 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3154 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3155 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3156 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003157 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003158 }
3159
3160 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3161 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003162 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003163 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3164 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003165 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003166 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3167 }
3168 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003169 }
3170
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003171 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003172 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3173 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003174
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003175 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3176 skip |=
3177 validate_struct_type("vkCreateGraphicsPipelines",
3178 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3179 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3180 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3181 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003182
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003183 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003184 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003185 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003186 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3187 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003188 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003189 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3190 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003191
Mike Schuchardt00e81452021-11-29 11:11:20 -08003192 skip |= validate_flags("vkCreateGraphicsPipelines",
3193 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3194 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003195 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003196 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003197
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003198 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003199 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3200 const auto *rasterization_order_attachment_access_feature =
3201 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3202 const bool rasterization_order_color_attachment_access_feature_enabled =
3203 rasterization_order_attachment_access_feature &&
3204 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3205
3206 if (!rasterization_order_color_attachment_access_feature_enabled) {
3207 skip |= LogError(
3208 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3209 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3210 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3211 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003212 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003213 }
3214
3215 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003216 skip |=
3217 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3218 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3219 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3220 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3221 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003222 }
3223 }
3224
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003225 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003226 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003227 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003228 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003229
3230 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003231 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003232 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3233 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003234 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3235 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003236
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003237 if (create_info.pColorBlendState->pAttachments != NULL) {
3238 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003239 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003240 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003241 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003242 ParameterName::IndexVector{i, attachment_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003243 create_info.pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003244
3245 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003246 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003247 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003248 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003249 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003250 create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003251 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003252
3253 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003254 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003255 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003256 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003257 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003258 create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003259 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003260
3261 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003262 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003263 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003264 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003265 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003266 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003267 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003268
3269 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003270 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003271 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003272 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003273 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003274 create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003275 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003276
3277 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003278 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003279 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003280 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003281 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003282 create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003283 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003284
3285 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003286 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003287 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003288 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003289 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003290 create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003291 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003292
3293 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003294 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003295 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003296 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003297 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003298 create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003299 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003300
3301 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3302 bool invalid = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003303 switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
ziga-lunarga283d022021-08-04 18:35:23 +02003304 case VK_BLEND_OP_ZERO_EXT:
3305 case VK_BLEND_OP_SRC_EXT:
3306 case VK_BLEND_OP_DST_EXT:
3307 case VK_BLEND_OP_SRC_OVER_EXT:
3308 case VK_BLEND_OP_DST_OVER_EXT:
3309 case VK_BLEND_OP_SRC_IN_EXT:
3310 case VK_BLEND_OP_DST_IN_EXT:
3311 case VK_BLEND_OP_SRC_OUT_EXT:
3312 case VK_BLEND_OP_DST_OUT_EXT:
3313 case VK_BLEND_OP_SRC_ATOP_EXT:
3314 case VK_BLEND_OP_DST_ATOP_EXT:
3315 case VK_BLEND_OP_XOR_EXT:
3316 case VK_BLEND_OP_INVERT_EXT:
3317 case VK_BLEND_OP_INVERT_RGB_EXT:
3318 case VK_BLEND_OP_LINEARDODGE_EXT:
3319 case VK_BLEND_OP_LINEARBURN_EXT:
3320 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3321 case VK_BLEND_OP_LINEARLIGHT_EXT:
3322 case VK_BLEND_OP_PINLIGHT_EXT:
3323 case VK_BLEND_OP_HARDMIX_EXT:
3324 case VK_BLEND_OP_PLUS_EXT:
3325 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3326 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3327 case VK_BLEND_OP_PLUS_DARKER_EXT:
3328 case VK_BLEND_OP_MINUS_EXT:
3329 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3330 case VK_BLEND_OP_CONTRAST_EXT:
3331 case VK_BLEND_OP_INVERT_OVG_EXT:
3332 case VK_BLEND_OP_RED_EXT:
3333 case VK_BLEND_OP_GREEN_EXT:
3334 case VK_BLEND_OP_BLUE_EXT:
3335 invalid = true;
3336 break;
3337 default:
3338 break;
3339 }
3340 if (invalid) {
3341 skip |= LogError(
3342 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3343 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3344 "].pColorBlendState->pAttachments[%" PRIu32
3345 "].colorBlendOp (%s) is not valid when "
3346 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3347 "VK_FALSE",
3348 i, attachment_index,
3349 string_VkBlendOp(
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003350 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp));
ziga-lunarga283d022021-08-04 18:35:23 +02003351 }
3352 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003353 }
3354 }
3355
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003356 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003357 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003358 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3359 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003360 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3361 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003362 }
3363
3364 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003365 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003366 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003367 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003368 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003369 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003370 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003371 }
3372 }
3373 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003374
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003375 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003376 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003377 if (create_info.basePipelineIndex != -1) {
3378 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003379 skip |=
3380 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003381 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3382 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003383 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003384 "and pCreateInfos->basePipelineIndex is not -1.",
3385 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003386 }
3387 }
3388
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003389 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3390 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003391 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003392 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3393 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003394 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003395 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3396 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003397 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003398 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003399 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003400 skip |=
3401 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003402 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3403 ") must be a valid"
3404 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003405 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003406 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003407 }
3408 }
3409
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003410 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003411 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003412 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003413 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003414 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3415 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3416 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3417 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003418 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003419 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003420 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003421 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003422 "pCreateInfos[%" PRIu32
3423 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003424 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3425 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003426 }
3427 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003428 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3429 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003430 (physical_device_features.fillModeNonSolid == false)) {
3431 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003432 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3433 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003434 "pCreateInfos[%" PRIu32
3435 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003436 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3437 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003438 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003439 }
Petr Kraus299ba622017-11-24 03:09:03 +01003440
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003441 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003442 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003443 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3444 "The line width state is static (pCreateInfos[%" PRIu32
3445 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3446 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3447 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003448 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003449 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003450 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003451
3452 // Validate no flags not allowed are used
3453 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003454 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003455 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3456 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003457 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3458 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003459 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003460 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3461 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003462 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003463 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3464 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003465 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3466 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003467 }
3468 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3469 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003470 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3471 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003472 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3473 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003474 }
3475 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3476 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003477 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3478 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003479 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3480 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003481 }
3482 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3483 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003484 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3485 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003486 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3487 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003488 }
3489 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3490 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003491 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3492 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003493 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3494 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003495 }
3496 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3497 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003498 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3499 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003500 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3501 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003502 }
3503 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3504 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003505 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3506 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003507 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3508 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003509 }
3510 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3511 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003512 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3513 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003514 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3515 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003516 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003517 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3518 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3519 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3520 "]->flags (0x%x) must not include "
3521 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3522 i, flags);
3523 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003524 }
3525 }
3526
3527 return skip;
3528}
3529
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003530bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3531 uint32_t createInfoCount,
3532 const VkComputePipelineCreateInfo *pCreateInfos,
3533 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003534 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003535 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003536 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003537 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003538 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003539 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003540 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003541 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003542 skip |=
Tony-LunarGce3244a2021-11-19 12:33:40 -07003543 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02669",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003544 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3545 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3546 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003547 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003548
3549 // Make sure compute stage is selected
3550 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003551 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003552 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3553 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003554 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003555 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003556
sfricke-samsungeb549012021-04-16 01:25:51 -07003557 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3558 // Validate no flags not allowed are used
3559 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003560 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3561 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3562 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3563 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003564 }
3565 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3566 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003567 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3568 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003569 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3570 i, flags);
3571 }
3572 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3573 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003574 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3575 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003576 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3577 i, flags);
3578 }
3579 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3580 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003581 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3582 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003583 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3584 i, flags);
3585 }
3586 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3587 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003588 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3589 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003590 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3591 i, flags);
3592 }
3593 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3594 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003595 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3596 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003597 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3598 i, flags);
3599 }
3600 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3601 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003602 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3603 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003604 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3605 i, flags);
3606 }
3607 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3608 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003609 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3610 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003611 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3612 i, flags);
3613 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003614 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3615 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003616 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3617 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003618 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3619 i, flags);
3620 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003621 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3622 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003623 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3624 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003625 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3626 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003627 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003628 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3629 if (pCreateInfos[i].basePipelineIndex != -1) {
3630 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3631 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3632 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3633 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3634 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3635 i);
3636 }
3637 }
3638
3639 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3640 if (pCreateInfos[i].basePipelineIndex != -1) {
3641 skip |= LogError(
3642 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3643 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3644 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3645 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3646 i);
3647 }
3648 } else {
3649 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3650 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3651 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3652 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3653 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3654 }
3655 }
3656 }
ziga-lunargc6341372021-07-28 12:57:42 +02003657
3658 std::stringstream msg;
3659 msg << "pCreateInfos[%" << i << "].stage";
3660 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003661 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003662 return skip;
3663}
3664
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003665bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003666 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003667 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003668
3669 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003670 const auto &features = physical_device_features;
3671 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003672
John Zulauf71968502017-10-26 13:51:15 -06003673 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3674 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003675 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3676 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3677 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3678 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003679 }
3680
3681 // Anistropy cannot be enabled in sampler unless enabled as a feature
3682 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003683 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3684 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3685 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003686 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003687 }
John Zulauf71968502017-10-26 13:51:15 -06003688
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003689 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3690 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003691 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3692 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3693 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3694 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003695 }
3696 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003697 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3698 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3699 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3700 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003701 }
3702 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003703 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3704 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3705 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3706 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003707 }
3708 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3709 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3710 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3711 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003712 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3713 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3714 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3715 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3716 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3717 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003718 }
3719 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003720 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3721 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3722 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003723 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003724 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003725 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3726 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3727 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003728 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003729 }
3730
3731 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3732 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003733 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3734 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003735 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003736 if (sampler_reduction != nullptr) {
3737 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3738 skip |= LogError(
3739 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3740 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3741 }
3742 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003743 }
3744
3745 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3746 // valid VkBorderColor value
3747 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3748 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3749 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003750 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3751 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003752 }
3753
John Zulauf275805c2017-10-26 15:34:49 -06003754 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003755 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003756 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3757 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003758 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3759 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3760 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003761 }
3762 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003763
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003764 // Check for valid Lod range
3765 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003766 skip |=
3767 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3768 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003769 }
3770
3771 // Check mipLodBias to device limit
3772 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003773 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3774 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3775 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003776 }
3777
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003778 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003779 if (sampler_conversion != nullptr) {
3780 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3781 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3782 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3783 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003784 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003785 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003786 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3787 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3788 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3789 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3790 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3791 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3792 }
3793 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003794
3795 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3796 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3797 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3798 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3799 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3800 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3801 }
3802 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3803 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3804 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3805 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3806 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3807 }
3808 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3809 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3810 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3811 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3812 pCreateInfo->minLod, pCreateInfo->maxLod);
3813 }
3814 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3815 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3816 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3817 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3818 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3819 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3820 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3821 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3822 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3823 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3824 }
3825 if (pCreateInfo->anisotropyEnable) {
3826 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3827 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3828 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3829 }
3830 if (pCreateInfo->compareEnable) {
3831 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3832 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3833 "pCreateInfo->compareEnable must be VK_FALSE");
3834 }
3835 if (pCreateInfo->unnormalizedCoordinates) {
3836 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3837 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3838 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3839 }
3840 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003841
Piers Daniell833b9492021-11-20 11:47:10 -07003842 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3843 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3844 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
3845 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3846 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3847 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3848 }
3849 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
3850 if (!custom_create_info) {
3851 skip |= LogError(
3852 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3853 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3854 "struct in pNext chain.\n",
3855 string_VkBorderColor(pCreateInfo->borderColor));
3856 } else {
3857 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3858 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
3859 !FormatIsSampledInt(custom_create_info->format)) ||
3860 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3861 !FormatIsSampledFloat(custom_create_info->format)))) {
3862 skip |=
3863 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06003864 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3865 "whose type does not match\n",
3866 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07003867 ;
3868 }
3869 }
3870 }
3871
3872 const auto *border_color_component_mapping =
3873 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
3874 if (border_color_component_mapping) {
3875 const auto *border_color_swizzle_features =
3876 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
3877 bool border_color_swizzle_features_enabled =
3878 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
3879 if (!border_color_swizzle_features_enabled) {
3880 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
3881 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
3882 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06003883 }
3884 }
3885 }
3886
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003887 return skip;
3888}
3889
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003890bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
3891 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
3892 const char *func_name) const {
3893 bool skip = false;
3894
3895 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
3896 uint32_t mutable_type_count = 0;
3897 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
3898 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
3899 }
3900 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3901 if (mutable_type_count == 0) {
3902 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
3903 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3904 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
3905 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3906 "].descriptorTypeCount is 0.",
3907 func_name, i, i);
3908 }
3909 } else {
3910 if (mutable_type_count > 0) {
3911 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
3912 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3913 "].descriptorType is %s, but "
3914 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3915 "].descriptorTypeCount is not 0.",
3916 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
3917 }
3918 }
3919 }
3920
3921 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
3922 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
3923 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
3924 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
3925 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
3926 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3927 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
3928 func_name, j, k);
3929 break;
3930 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
3931 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
3932 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3933 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
3934 func_name, j, k);
3935 break;
3936 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
3937 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
3938 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3939 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
3940 func_name, j, k);
3941 break;
3942 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
3943 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
3944 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3945 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
3946 func_name, j, k);
3947 break;
3948 default:
3949 break;
3950 }
3951 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
3952 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
3953 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
3954 skip |=
3955 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
3956 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3957 "].pDescriptorTypes[%" PRIu32
3958 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3959 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
3960 func_name, j, k, j, l,
3961 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
3962 }
3963 }
3964 }
3965 }
3966
3967 return skip;
3968}
3969
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003970bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3971 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3972 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003973 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003974 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003975
ziga-lunargfc6896f2021-10-15 18:46:12 +02003976 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
3977 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
3978 bool mutable_descriptor_type_features_enabled =
3979 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
3980
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003981 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3982 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3983 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3984 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003985 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3986 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3987 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3988 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3989 ++descriptor_index) {
3990 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003991 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003992 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003993 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
3994 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003995 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003996 }
3997 }
3998 }
3999
4000 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4001 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4002 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004003 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004004 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4005 "].descriptorCount is not 0, "
4006 "pCreateInfo->pBindings[%" PRIu32
4007 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004008 "values.",
4009 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004010 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004011
4012 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4013 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4014 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004015 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4016 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4017 "].descriptorCount is not 0 and "
4018 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4019 "].stageFlags "
4020 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4021 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004022 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004023
4024 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4025 if (!mutable_descriptor_type) {
4026 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4027 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4028 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4029 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4030 i);
4031 }
4032 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4033 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4034 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4035 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4036 "pImmutableSamplers is not NULL.",
4037 i);
4038 }
4039 if (!mutable_descriptor_type_features_enabled) {
4040 skip |= LogError(
4041 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4042 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4043 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4044 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4045 i);
4046 }
4047 }
4048
4049 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4050 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4051 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4052 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4053 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4054 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4055 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004056 }
4057 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004058
4059 if (mutable_descriptor_type) {
4060 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
4061 "vkDescriptorSetLayoutCreateInfo");
4062 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004063 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004064 if (pCreateInfo) {
4065 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4066 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4067 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4068 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4069 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4070 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4071 }
4072 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4073 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4074 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4075 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4076 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4077 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4078 }
4079 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4080 !mutable_descriptor_type_features_enabled) {
4081 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4082 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4083 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4084 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4085 }
4086 }
4087
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004088 return skip;
4089}
4090
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004091bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4092 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004093 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004094 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4095 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4096 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004097 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4098 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004099}
4100
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004101bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4102 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004103 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004104 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004105
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004106 if (pDescriptorWrites != NULL) {
4107 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4108 // descriptorCount must be greater than 0
4109 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004110 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4111 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4112 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004113 }
4114
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004115 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004116 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004117 // dstSet must be a valid VkDescriptorSet handle
4118 skip |= validate_required_handle(vkCallingFunction,
4119 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4120 pDescriptorWrites[i].dstSet);
4121 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004122
4123 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4124 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4125 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4126 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4127 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004128 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004129 if (!isPushDescriptor) {
4130 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4131 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4132 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4133 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4134 // ObjectLifetimes::ValidateDescriptorWrite.
4135 skip |= LogError(
4136 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4137 "%s(): if pDescriptorWrites[%" PRIu32
4138 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4139 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4140 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4141 vkCallingFunction, i, i);
4142 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4143 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4144 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4145 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4146 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4147 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4148 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4149 "%s(): if pDescriptorWrites[%" PRIu32
4150 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4151 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4152 "].pImageInfo must not be NULL.",
4153 vkCallingFunction, i, i);
4154 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004155 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4156 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004157 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4158 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004159 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4160 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004161 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004162 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4163 ParameterName::IndexVector{i, descriptor_index}),
4164 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004165 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004166 }
4167 }
4168 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4169 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4170 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4171 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4172 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4173 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4174 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004175 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004176 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004177 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004178 "%s(): if pDescriptorWrites[%" PRIu32
4179 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004180 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4181 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004182 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004183 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004184 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004185 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004186 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004187 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004188 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4189 ++descriptor_index) {
4190 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4191 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4192 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004193 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004194 "%s(): if pDescriptorWrites[%" PRIu32
4195 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004196 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004197 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4198 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004199 }
4200 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004201 }
4202 }
4203 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4204 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004205 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004206 }
4207
4208 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4209 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004210 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004211 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4212 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004213 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004214 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004215 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004216 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004217 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004218 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004219 }
4220 }
4221 }
4222 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4223 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004224 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004225 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4226 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004227 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004228 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004229 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004230 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004231 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004232 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004233 }
4234 }
4235 }
4236 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004237 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4238 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004239 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004240 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004241 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4242 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4243 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4244 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004245 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004246 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4247 pDescriptorWrites[i].descriptorCount);
4248 }
4249 // further checks only if we have right structtype
4250 if (pnext_struct) {
4251 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4252 skip |= LogError(
4253 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004254 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4255 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004256 ".",
4257 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004258 }
sourav parmarbcee7512020-12-28 14:34:49 -08004259 if (pnext_struct->accelerationStructureCount == 0) {
4260 skip |= LogError(device,
4261 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004262 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004263 }
4264 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004265 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004266 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4267 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4268 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4269 skip |= LogError(device,
4270 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4271 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004272 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004273 }
4274 }
4275 }
sourav parmarbcee7512020-12-28 14:34:49 -08004276 }
4277 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004278 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004279 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4280 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4281 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4282 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004283 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004284 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4285 pDescriptorWrites[i].descriptorCount);
4286 }
4287 // further checks only if we have right structtype
4288 if (pnext_struct) {
4289 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4290 skip |= LogError(
4291 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004292 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4293 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004294 ".",
4295 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004296 }
sourav parmarbcee7512020-12-28 14:34:49 -08004297 if (pnext_struct->accelerationStructureCount == 0) {
4298 skip |= LogError(device,
4299 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004300 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004301 }
4302 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004303 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004304 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4305 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4306 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4307 skip |= LogError(device,
4308 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4309 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004310 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004311 }
4312 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004313 }
4314 }
4315 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004316 }
4317 }
4318 return skip;
4319}
4320
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004321bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4322 const VkWriteDescriptorSet *pDescriptorWrites,
4323 uint32_t descriptorCopyCount,
4324 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004325 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004326}
4327
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004328bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004329 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004330 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004331 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4332}
4333
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004334bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4335 const VkAllocationCallbacks *pAllocator,
4336 VkRenderPass *pRenderPass) const {
4337 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4338}
4339
Mike Schuchardt2df08912020-12-15 16:28:09 -08004340bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004341 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004342 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004343 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4344}
4345
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004346bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4347 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004348 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004349 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004350
4351 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4352 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4353 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004354 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4355 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004356 return skip;
4357}
4358
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004359bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004360 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004361 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004362
4363 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4364 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004365 bool cb_is_secondary;
4366 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004367 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004368 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4369 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004370
Tony-LunarG3c287f62020-12-17 12:39:49 -07004371 if (cb_is_secondary) {
4372 // Implicit VUs
4373 // validate only sType here; pointer has to be validated in core_validation
4374 const bool k_not_required = false;
4375 const char *k_no_vuid = nullptr;
4376 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4377 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004378 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4379 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004380
Tony-LunarG3c287f62020-12-17 12:39:49 -07004381 if (info) {
4382 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004383 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004384 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4385 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004386 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004387 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004388 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4389 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4390 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4391 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004392
Tony-LunarG3c287f62020-12-17 12:39:49 -07004393 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004394
Tony-LunarG3c287f62020-12-17 12:39:49 -07004395 // Explicit VUs
4396 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004397 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004398 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4399 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4400 cmd_name);
4401 }
4402
4403 if (physical_device_features.inheritedQueries) {
4404 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004405 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4406 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4407 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004408 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004409 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004410 }
4411
4412 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004413 skip |=
4414 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4415 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4416 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4417 } else { // !pipelineStatisticsQuery
4418 skip |=
4419 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4420 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004421 }
4422
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004423 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004424 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004425 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004426 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4427 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4428 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004429 commandBuffer,
4430 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004431 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4432 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4433 }
Petr Kraus139757b2019-08-15 17:19:33 +02004434 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004435
4436 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4437 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4438 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4439 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4440 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4441 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4442 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4443 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4444 }
Petr Kraus139757b2019-08-15 17:19:33 +02004445 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004446 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004447 return skip;
4448}
4449
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004450bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004451 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004452 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004453
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004454 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004455 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004456 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4457 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4458 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004459 }
4460 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004461 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4462 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4463 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004464 }
4465 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004466 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004467 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004468 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4469 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4470 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4471 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004472 }
4473 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004474
4475 if (pViewports) {
4476 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4477 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004478 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004479 skip |= manual_PreCallValidateViewport(
4480 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004481 }
4482 }
4483
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004484 return skip;
4485}
4486
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004487bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004488 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004489 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004490
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004491 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004492 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004493 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4494 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4495 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004496 }
4497 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004498 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4499 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4500 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004501 }
4502 } else { // multiViewport enabled
4503 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004504 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004505 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4506 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4507 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4508 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004509 }
4510 }
4511
Petr Kraus6260f0a2018-02-27 21:15:55 +01004512 if (pScissors) {
4513 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4514 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004515
Petr Kraus6260f0a2018-02-27 21:15:55 +01004516 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004517 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4518 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4519 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004520 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004521
Petr Kraus6260f0a2018-02-27 21:15:55 +01004522 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004523 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4524 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4525 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004526 }
4527
4528 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4529 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004530 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4531 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4532 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4533 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004534 }
4535
4536 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4537 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004538 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4539 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4540 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4541 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004542 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004543 }
4544 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004545
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004546 return skip;
4547}
4548
Jeff Bolz5c801d12019-10-09 10:38:45 -05004549bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004550 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004551
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004552 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004553 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4554 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004555 }
4556
4557 return skip;
4558}
4559
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004560bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004561 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004562 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004563
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004564 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004565 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004566 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4567 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004568 }
4569 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004570 skip |=
4571 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4572 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4573 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004574 }
4575 return skip;
4576}
4577
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004578bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004579 VkDeviceSize offset, uint32_t drawCount,
4580 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004581 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004582 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004583 skip |=
4584 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4585 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4586 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004587 }
4588 if (drawCount > device_limits.maxDrawIndirectCount) {
4589 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004590 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4591 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004592 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004593 }
4594 return skip;
4595}
4596
sfricke-samsungf692b972020-05-02 08:00:45 -07004597bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4598 VkDeviceSize countBufferOffset, bool khr) const {
4599 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004600 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004601 if (offset & 3) {
4602 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004603 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004604 }
4605
4606 if (countBufferOffset & 3) {
4607 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004608 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004609 countBufferOffset);
4610 }
4611 return skip;
4612}
4613
4614bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4615 VkDeviceSize offset, VkBuffer countBuffer,
4616 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4617 uint32_t stride) const {
4618 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4619}
4620
4621bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4622 VkDeviceSize offset, VkBuffer countBuffer,
4623 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4624 uint32_t stride) const {
4625 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4626}
4627
4628bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4629 VkDeviceSize countBufferOffset, bool khr) const {
4630 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004631 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004632 if (offset & 3) {
4633 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004634 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004635 }
4636
4637 if (countBufferOffset & 3) {
4638 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004639 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004640 countBufferOffset);
4641 }
4642 return skip;
4643}
4644
4645bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4646 VkDeviceSize offset, VkBuffer countBuffer,
4647 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4648 uint32_t stride) const {
4649 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4650}
4651
4652bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4653 VkDeviceSize offset, VkBuffer countBuffer,
4654 VkDeviceSize countBufferOffset,
4655 uint32_t maxDrawCount, uint32_t stride) const {
4656 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4657}
4658
Tony-LunarG4490de42021-06-21 15:49:19 -06004659bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4660 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4661 uint32_t firstInstance, uint32_t stride) const {
4662 bool skip = false;
4663 if (stride & 3) {
4664 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4665 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4666 }
4667 if (drawCount && nullptr == pVertexInfo) {
4668 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4669 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4670 "one or more valid instances of VkMultiDrawInfoEXT structures");
4671 }
4672 return skip;
4673}
4674
4675bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4676 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4677 uint32_t instanceCount, uint32_t firstInstance,
4678 uint32_t stride, const int32_t *pVertexOffset) const {
4679 bool skip = false;
4680 if (stride & 3) {
4681 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4682 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4683 }
4684 if (drawCount && nullptr == pIndexInfo) {
4685 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4686 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4687 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4688 }
4689 return skip;
4690}
4691
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004692bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4693 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004694 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004695 bool skip = false;
4696 for (uint32_t rect = 0; rect < rectCount; rect++) {
4697 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004698 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004699 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004700 }
sfricke-samsung10867682020-04-25 02:20:39 -07004701 if (pRects[rect].rect.extent.width == 0) {
4702 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004703 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004704 }
4705 if (pRects[rect].rect.extent.height == 0) {
4706 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004707 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004708 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004709 }
4710 return skip;
4711}
4712
Andrew Fobel3abeb992020-01-20 16:33:22 -05004713bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4714 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4715 VkImageFormatProperties2 *pImageFormatProperties,
4716 const char *apiName) const {
4717 bool skip = false;
4718
4719 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004720 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004721 if (image_stencil_struct != nullptr) {
4722 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4723 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4724 // No flags other than the legal attachment bits may be set
4725 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4726 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004727 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4728 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4729 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4730 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4731 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004732 }
4733 }
4734 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004735 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4736 if (image_drm_format) {
4737 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4738 skip |= LogError(
4739 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4740 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4741 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4742 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4743 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004744 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4745 skip |= LogError(
4746 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4747 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4748 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4749 apiName, image_drm_format->queueFamilyIndexCount);
4750 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004751 } else {
4752 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4753 skip |= LogError(
4754 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4755 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4756 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4757 apiName);
4758 }
4759 }
4760 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4761 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4762 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4763 if (!format_list || format_list->viewFormatCount == 0) {
4764 skip |= LogError(
4765 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4766 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4767 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4768 apiName);
4769 }
4770 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004771 }
4772
4773 return skip;
4774}
4775
4776bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4777 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4778 VkImageFormatProperties2 *pImageFormatProperties) const {
4779 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4780 "vkGetPhysicalDeviceImageFormatProperties2");
4781}
4782
4783bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4784 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4785 VkImageFormatProperties2 *pImageFormatProperties) const {
4786 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4787 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4788}
4789
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004790bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4791 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4792 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4793 bool skip = false;
4794
4795 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4796 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4797 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4798 }
4799
4800 return skip;
4801}
4802
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004803bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4804 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4805 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4806 bool skip = false;
4807
4808 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4809 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4810 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4811 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4812 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4813 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4814 }
4815
ziga-lunarg42f884b2021-08-25 16:13:20 +02004816 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004817}
4818
sfricke-samsung3999ef62020-02-09 17:05:59 -08004819bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4820 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4821 bool skip = false;
4822
4823 if (pRegions != nullptr) {
4824 for (uint32_t i = 0; i < regionCount; i++) {
4825 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004826 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004827 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004828 }
4829 }
4830 }
4831 return skip;
4832}
4833
Jeff Leger178b1e52020-10-05 12:22:23 -04004834bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4835 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4836 bool skip = false;
4837
4838 if (pCopyBufferInfo->pRegions != nullptr) {
4839 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4840 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06004841 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004842 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004843 }
4844 }
4845 }
4846 return skip;
4847}
4848
Tony-LunarGef035472021-11-02 10:23:33 -06004849bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
4850 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
4851 bool skip = false;
4852
4853 if (pCopyBufferInfo->pRegions != nullptr) {
4854 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4855 if (pCopyBufferInfo->pRegions[i].size == 0) {
4856 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
4857 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
4858 }
4859 }
4860 }
4861 return skip;
4862}
4863
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004864bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004865 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4866 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004867 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004868
4869 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004870 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4871 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4872 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004873 }
4874
4875 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004876 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4877 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4878 "), must be greater than zero and less than or equal to 65536.",
4879 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004880 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004881 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4882 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4883 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004884 }
4885 return skip;
4886}
4887
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004888bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004889 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004890 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004891
4892 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004893 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4894 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4895 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004896 }
4897
4898 if (size != VK_WHOLE_SIZE) {
4899 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004900 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004901 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4902 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004903 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004904 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4905 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004906 }
4907 }
4908 return skip;
4909}
4910
sfricke-samsunga1d00272021-03-10 21:37:41 -08004911bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004912 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004913
4914 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004915 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4916 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4917 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4918 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004919 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004920 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4921 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4922 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004923 }
4924
4925 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4926 // queueFamilyIndexCount uint32_t values
4927 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004928 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004929 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004930 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004931 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4932 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004933 }
4934 }
4935
Dave Houlton413a6782018-05-22 13:01:54 -06004936 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004937 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004938
sfricke-samsunga1d00272021-03-10 21:37:41 -08004939 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4940 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4941 if (format_list_info) {
4942 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4943 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4944 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4945 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004946 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
4947 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004948 func_name, viewFormatCount);
4949 }
4950
4951 // Using the first format, compare the rest of the formats against it that they are compatible
4952 for (uint32_t i = 1; i < viewFormatCount; i++) {
4953 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4954 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4955 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4956 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004957 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
4958 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004959 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4960 string_VkFormat(format_list_info->pViewFormats[i]));
4961 }
4962 }
4963 }
4964
4965 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4966 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4967 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4968 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4969 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4970 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4971 func_name);
4972 } else {
4973 if (format_list_info == nullptr) {
4974 skip |= LogError(
4975 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4976 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4977 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4978 func_name);
4979 } else if (format_list_info->viewFormatCount == 0) {
4980 skip |= LogError(
4981 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4982 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4983 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4984 func_name);
4985 } else {
4986 bool found_base_format = false;
4987 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4988 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4989 found_base_format = true;
4990 break;
4991 }
4992 }
4993 if (!found_base_format) {
4994 skip |=
4995 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4996 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4997 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4998 "pCreateInfo->imageFormat.",
4999 func_name);
5000 }
5001 }
5002 }
5003 }
5004 }
5005 return skip;
5006}
5007
5008bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5009 const VkAllocationCallbacks *pAllocator,
5010 VkSwapchainKHR *pSwapchain) const {
5011 bool skip = false;
5012 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5013 return skip;
5014}
5015
5016bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5017 const VkSwapchainCreateInfoKHR *pCreateInfos,
5018 const VkAllocationCallbacks *pAllocator,
5019 VkSwapchainKHR *pSwapchains) const {
5020 bool skip = false;
5021 if (pCreateInfos) {
5022 for (uint32_t i = 0; i < swapchainCount; i++) {
5023 std::stringstream func_name;
5024 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5025 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5026 }
5027 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005028 return skip;
5029}
5030
Jeff Bolz5c801d12019-10-09 10:38:45 -05005031bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005032 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005033
5034 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005035 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005036 if (present_regions) {
5037 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005038 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005039 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5040 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005041 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005042 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5043 "extension swapchainCount is %i. These values must be equal.",
5044 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005045 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005046 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005047 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5048 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005049 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5050 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5051 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005052 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005053 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005054 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005055 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005056 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005057 }
5058 }
5059
5060 return skip;
5061}
5062
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005063bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5064 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5065 const VkAllocationCallbacks *pAllocator,
5066 VkDisplayModeKHR *pMode) const {
5067 bool skip = false;
5068
5069 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5070 if (display_mode_parameters.visibleRegion.width == 0) {
5071 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5072 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5073 }
5074 if (display_mode_parameters.visibleRegion.height == 0) {
5075 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5076 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5077 }
5078 if (display_mode_parameters.refreshRate == 0) {
5079 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5080 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5081 }
5082
5083 return skip;
5084}
5085
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005086#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005087bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5088 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5089 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005090 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005091 bool skip = false;
5092
5093 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005094 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5095 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005096 }
5097
5098 return skip;
5099}
5100#endif // VK_USE_PLATFORM_WIN32_KHR
5101
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005102static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5103 bool partial_overlap = false;
5104
5105 static const std::vector<VkDescriptorType> all_descriptor_types = {
5106 VK_DESCRIPTOR_TYPE_SAMPLER,
5107 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5108 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5109 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5110 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5111 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5112 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5113 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5114 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5115 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5116 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5117 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5118 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5119 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5120 };
5121
5122 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5123 if (mutable_descriptor_type) {
5124 std::vector<VkDescriptorType> first_types, second_types;
5125 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5126 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5127 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5128 }
5129 } else {
5130 first_types = all_descriptor_types;
5131 }
5132 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5133 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5134 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5135 }
5136 } else {
5137 second_types = all_descriptor_types;
5138 }
5139
5140 bool complete_overlap = first_types.size() == second_types.size();
5141 bool disjoint = true;
5142 for (const auto first_type : first_types) {
5143 bool found = false;
5144 for (const auto second_type : second_types) {
5145 if (first_type == second_type) {
5146 found = true;
5147 break;
5148 }
5149 }
5150 if (found) {
5151 disjoint = false;
5152 } else {
5153 complete_overlap = false;
5154 }
5155 if (!disjoint && !complete_overlap) {
5156 partial_overlap = true;
5157 break;
5158 }
5159 }
5160 }
5161
5162 return partial_overlap;
5163}
5164
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005165bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005166 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005167 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005168 bool skip = false;
5169
5170 if (pCreateInfo) {
5171 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005172 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5173 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005174 }
5175
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005176 const auto *mutable_descriptor_type_features =
5177 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5178 bool mutable_descriptor_type_enabled =
5179 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5180
Petr Krausc8655be2017-09-27 18:56:51 +02005181 if (pCreateInfo->pPoolSizes) {
5182 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5183 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005184 skip |= LogError(
5185 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005186 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005187 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005188 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5189 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005190 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5191 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5192 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5193 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5194 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005195 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005196 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5197 skip |=
5198 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5199 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5200 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5201 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5202 i);
5203 }
5204 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5205 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5206 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5207 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5208 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5209 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5210 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5211 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5212 " and have sets which partially overlap.",
5213 i, j);
5214 }
5215 }
5216 }
5217 }
Petr Krausc8655be2017-09-27 18:56:51 +02005218 }
5219 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005220
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005221 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5222 skip |=
5223 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5224 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5225 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5226 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005227 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5228 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5229 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5230 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5231 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5232 }
Petr Krausc8655be2017-09-27 18:56:51 +02005233 }
5234
5235 return skip;
5236}
5237
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005238bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005239 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005240 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005241
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005242 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005243 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005244 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5245 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5246 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005247 }
5248
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005249 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005250 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005251 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5252 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5253 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005254 }
5255
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005256 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005257 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005258 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5259 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5260 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005261 }
5262
5263 return skip;
5264}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005265
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005266bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005267 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005268 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005269
5270 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005271 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5272 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005273 }
5274 return skip;
5275}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005276
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005277bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5278 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005279 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005280 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005281
5282 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005283 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005284 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005285 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5286 "vkCmdDispatch(): baseGroupX (%" PRIu32
5287 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5288 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005289 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005290 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5291 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5292 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5293 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005294 }
5295
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005296 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005297 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005298 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5299 "vkCmdDispatch(): baseGroupY (%" PRIu32
5300 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5301 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005302 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005303 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5304 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5305 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5306 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005307 }
5308
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005309 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005310 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005311 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5312 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5313 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5314 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005315 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005316 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5317 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5318 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5319 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005320 }
5321
5322 return skip;
5323}
5324
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005325bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5326 VkPipelineBindPoint pipelineBindPoint,
5327 VkPipelineLayout layout, uint32_t set,
5328 uint32_t descriptorWriteCount,
5329 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005330 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005331}
5332
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005333bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5334 uint32_t firstExclusiveScissor,
5335 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005336 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005337 bool skip = false;
5338
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005339 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005340 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005341 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005342 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5343 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5344 ") is not 0.",
5345 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005346 }
5347 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005348 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005349 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5350 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5351 ") is not 1.",
5352 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005353 }
5354 } else { // multiViewport enabled
5355 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005356 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005357 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5358 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5359 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5360 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005361 }
5362 }
5363
Jeff Bolz3e71f782018-08-29 23:15:45 -05005364 if (pExclusiveScissors) {
5365 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5366 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5367
5368 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005369 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5370 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5371 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005372 }
5373
5374 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005375 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5376 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5377 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005378 }
5379
5380 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5381 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005382 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5383 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5384 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5385 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005386 }
5387
5388 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5389 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005390 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5391 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5392 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5393 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005394 }
5395 }
5396 }
5397
5398 return skip;
5399}
5400
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005401bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5402 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005403 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005404 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005405 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5406 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5407 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5408 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5409 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5410 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005411 }
5412
5413 return skip;
5414}
5415
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005416bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5417 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005418 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005419 bool skip = false;
5420
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005421 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005422 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005423 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005424 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5425 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5426 ") is not 0.",
5427 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005428 }
5429 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005430 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005431 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5432 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5433 ") is not 1.",
5434 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005435 }
5436 }
5437
Jeff Bolz9af91c52018-09-01 21:53:57 -05005438 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005439 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005440 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5441 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5442 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5443 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005444 }
5445
5446 return skip;
5447}
5448
Jeff Bolz5c801d12019-10-09 10:38:45 -05005449bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5450 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5451 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005452 bool skip = false;
5453
Dave Houlton142c4cb2018-10-17 15:04:41 -06005454 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005455 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5456 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5457 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005458 }
5459
5460 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005461 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005462 }
5463
5464 return skip;
5465}
5466
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005467bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005468 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005469 bool skip = false;
5470
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005471 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005472 skip |= LogError(
5473 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005474 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5475 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005476 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005477 }
5478
5479 return skip;
5480}
5481
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005482bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5483 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005484 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005485 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005486 static const int condition_multiples = 0b0011;
5487 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005488 skip |= LogError(
5489 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005490 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005491 }
Lockee1c22882019-06-10 16:02:54 -06005492 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005493 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5494 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5495 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5496 stride);
Lockee1c22882019-06-10 16:02:54 -06005497 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005498 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005499 skip |= LogError(
5500 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005501 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5502 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005503 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005504 if (drawCount > device_limits.maxDrawIndirectCount) {
5505 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005506 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5507 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005508 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005509 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005510 return skip;
5511}
5512
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005513bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5514 VkDeviceSize offset, VkBuffer countBuffer,
5515 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005516 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005517 bool skip = false;
5518
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005519 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005520 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5521 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5522 "), is not a multiple of 4.",
5523 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005524 }
5525
5526 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005527 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5528 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5529 "), is not a multiple of 4.",
5530 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005531 }
5532
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005533 return skip;
5534}
5535
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005536bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005537 const VkAllocationCallbacks *pAllocator,
5538 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005539 bool skip = false;
5540
5541 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5542 if (pCreateInfo != nullptr) {
5543 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5544 // VkQueryPipelineStatisticFlagBits values
5545 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5546 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005547 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5548 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5549 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5550 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005551 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005552 if (pCreateInfo->queryCount == 0) {
5553 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5554 "vkCreateQueryPool(): queryCount must be greater than zero.");
5555 }
ziga-lunarg1052d492022-04-03 20:12:15 +02005556 if (pCreateInfo->queryType == VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT) {
5557 const auto *primitives_generated_query_features =
5558 LvlFindInChain<VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT>(device_createinfo_pnext);
5559 if (!primitives_generated_query_features || primitives_generated_query_features->primitivesGeneratedQuery == VK_FALSE) {
5560 skip |= LogError(device, "VUID-vkCmdBeginQuery-queryType-06688",
5561 "vkCreateQueryPool(): If pCreateInfo->queryType is VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT primitivesGeneratedQuery feature must be enabled.");
5562 }
5563 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005564 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005565 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005566}
5567
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005568bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5569 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005570 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005571 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5572 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005573}
5574
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005575void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005576 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5577 VkResult result) {
5578 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005579 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005580}
5581
Mike Schuchardt2df08912020-12-15 16:28:09 -08005582void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005583 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5584 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005585 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005586 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005587 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005588}
5589
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005590void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5591 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005592 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005593 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005594 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005595}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005596
Tony-LunarG3c287f62020-12-17 12:39:49 -07005597void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005598 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005599 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005600 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005601 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005602 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005603 }
5604 }
5605}
5606
5607void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005608 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005609 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005610 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5611 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5612 }
5613}
5614
5615void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005616 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005617 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005618 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5619 if (item->second == commandPool) {
5620 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005621 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005622 ++item;
5623 }
5624 }
5625}
5626
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005627bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005628 const VkAllocationCallbacks *pAllocator,
5629 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005630 bool skip = false;
5631
5632 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005633 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005634 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005635 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5636 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005637 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005638
5639 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005640 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005641 if (flags_info) {
5642 flags = flags_info->flags;
5643 }
5644
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005645 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005646 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005647 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005648 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5649 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005650 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005651 }
5652
5653#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005654 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005655#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005656 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5657 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005658#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005659 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005660#endif
5661
5662 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005663 skip |= LogError(
5664 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005665 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5666 }
5667 if (
5668#ifdef VK_USE_PLATFORM_WIN32_KHR
5669 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5670#endif
5671 (import_memory_fd && import_memory_fd->handleType) ||
5672#ifdef VK_USE_PLATFORM_ANDROID_KHR
5673 (import_memory_ahb && import_memory_ahb->buffer) ||
5674#endif
5675 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005676 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5677 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005678 }
5679 }
5680
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005681 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5682 if (export_memory) {
5683 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5684 if (export_memory_nv) {
5685 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5686 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5687 "VkExportMemoryAllocateInfoNV");
5688 }
5689#ifdef VK_USE_PLATFORM_WIN32_KHR
5690 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5691 if (export_memory_win32_nv) {
5692 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5693 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5694 "VkExportMemoryWin32HandleInfoNV");
5695 }
5696#endif
5697 }
5698
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005699 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005700 VkBool32 capture_replay = false;
5701 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005702 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005703 if (vulkan_12_features) {
5704 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5705 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5706 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005707 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005708 if (bda_features) {
5709 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5710 buffer_device_address = bda_features->bufferDeviceAddress;
5711 }
5712 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005713 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005714 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005715 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005716 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005717 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005718 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005719 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005720 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005721 }
5722 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005723 }
5724 return skip;
5725}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005726
Jason Macnak192fa0e2019-07-26 15:07:16 -07005727bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005728 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005729 bool skip = false;
5730
5731 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5732 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5733 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005734 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005735 } else {
5736 uint32_t vertex_component_size = 0;
5737 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5738 vertex_component_size = 4;
5739 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5740 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5741 vertex_component_size = 2;
5742 }
5743 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005744 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005745 }
5746 }
5747
5748 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5749 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005750 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005751 } else {
5752 uint32_t index_element_size = 0;
5753 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5754 index_element_size = 4;
5755 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5756 index_element_size = 2;
5757 }
5758 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005759 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005760 }
5761 }
5762 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5763 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005764 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005765 }
5766 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005767 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005768 }
5769 }
5770
5771 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005772 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005773 }
5774
5775 return skip;
5776}
5777
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005778bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5779 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005780 bool skip = false;
5781
5782 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005783 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005784 }
5785 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005786 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005787 }
5788
5789 return skip;
5790}
5791
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005792bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5793 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005794 bool skip = false;
5795 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005796 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005797 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005798 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005799 }
5800 return skip;
5801}
5802
5803bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005804 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005805 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005806 bool skip = false;
5807 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005808 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5809 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5810 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005811 }
5812 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005813 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5814 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5815 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005816 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005817 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5818 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5819 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5820 }
Jason Macnak5c954952019-07-09 15:46:12 -07005821 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5822 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005823 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5824 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5825 "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 -07005826 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005827 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005828 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005829 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5830 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005831 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5832 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005833 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005834 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005835 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5836 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5837 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005838 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005839 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005840 uint64_t total_triangle_count = 0;
5841 for (uint32_t i = 0; i < info.geometryCount; i++) {
5842 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005843
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005844 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005845
Jason Macnak5c954952019-07-09 15:46:12 -07005846 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5847 continue;
5848 }
5849 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5850 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005851 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005852 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5853 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5854 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005855 }
5856 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005857 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5858 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5859 for (uint32_t i = 1; i < info.geometryCount; i++) {
5860 const VkGeometryNV &geometry = info.pGeometries[i];
5861 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005862 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005863 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5864 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005865 "info.pGeometries[0].geometryType.",
5866 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005867 }
5868 }
5869 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005870 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5871 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5872 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5873 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5874 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5875 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5876 }
5877 }
5878 skip |=
5879 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005880 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005881 return skip;
5882}
5883
Ricardo Garciaa4935972019-02-21 17:43:18 +01005884bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5885 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005886 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005887 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005888 if (pCreateInfo) {
5889 if ((pCreateInfo->compactedSize != 0) &&
5890 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005891 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5892 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5893 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5894 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005895 }
Jason Macnak5c954952019-07-09 15:46:12 -07005896
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005897 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005898 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005899 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005900 return skip;
5901}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005902
Jeff Bolz5c801d12019-10-09 10:38:45 -05005903bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5904 const VkAccelerationStructureInfoNV *pInfo,
5905 VkBuffer instanceData, VkDeviceSize instanceOffset,
5906 VkBool32 update, VkAccelerationStructureNV dst,
5907 VkAccelerationStructureNV src, VkBuffer scratch,
5908 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005909 bool skip = false;
5910
5911 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005912 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005913 }
5914
5915 return skip;
5916}
5917
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005918bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5919 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5920 VkAccelerationStructureKHR *pAccelerationStructure) const {
5921 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005922 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005923 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005924 if (!acceleration_structure_features ||
5925 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5926 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5927 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5928 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005929 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005930 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5931 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005932 (acceleration_structure_features &&
5933 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005934 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005935 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5936 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5937 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5938 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005939 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005940 if (pCreateInfo->deviceAddress &&
5941 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5942 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5943 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5944 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5945 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005946 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5947 (acceleration_structure_features &&
5948 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5949 skip |= LogError(
5950 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5951 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5952 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5953 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005954 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5955 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005956 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5957 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005958 }
sourav parmar83c31b12020-05-06 12:30:54 -07005959 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005960 return skip;
5961}
5962
Jason Macnak5c954952019-07-09 15:46:12 -07005963bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5964 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005965 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005966 bool skip = false;
5967 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005968 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5969 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005970 }
5971 return skip;
5972}
5973
sourav parmarcd5fb182020-07-17 12:58:44 -07005974bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5975 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5976 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5977 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005978 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005979 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005980 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005981 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005982 }
5983 return skip;
5984}
5985
Peter Chen85366392019-05-14 15:20:11 -04005986bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5987 uint32_t createInfoCount,
5988 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5989 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005990 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005991 bool skip = false;
5992
5993 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005994 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5995 std::stringstream msg;
5996 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5997 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5998 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005999 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006000 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Tony-LunarGce3244a2021-11-19 12:33:40 -07006001 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006002 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6003 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6004 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6005 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006006 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006007
6008 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006009 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006010 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6011 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6012 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6013 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6014 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6015 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6016 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6017 }
6018 }
6019
sourav parmarf4a78252020-04-10 13:04:21 -07006020 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6021 skip |=
6022 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6023 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6024 }
6025 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6026 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6027 skip |=
6028 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6029 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6030 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6031 }
6032 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6033 if (pCreateInfos[i].basePipelineIndex != -1) {
6034 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6035 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6036 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6037 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6038 "and pCreateInfos->basePipelineIndex is not -1.");
6039 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006040 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006041 skip |=
6042 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6043 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6044 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6045 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6046 "that element.");
6047 }
sourav parmarf4a78252020-04-10 13:04:21 -07006048 }
6049 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006050 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006051 skip |=
6052 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6053 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6054 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6055 "commands pCreateInfos parameter.");
6056 }
6057 } else {
6058 if (pCreateInfos[i].basePipelineIndex != -1) {
6059 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6060 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6061 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6062 }
6063 }
6064 }
6065 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6066 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6067 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6068 }
6069 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6070 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6071 "vkCreateRayTracingPipelinesNV: flags must not include "
6072 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6073 }
6074 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6075 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6076 "vkCreateRayTracingPipelinesNV: flags must not include "
6077 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6078 }
6079 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6080 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6081 "vkCreateRayTracingPipelinesNV: flags must not include "
6082 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6083 }
6084 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6085 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6086 "vkCreateRayTracingPipelinesNV: flags must not include "
6087 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6088 }
6089 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6090 skip |= LogError(
6091 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6092 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6093 }
6094 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6095 skip |= LogError(
6096 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6097 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6098 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006099 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6100 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6101 "vkCreateRayTracingPipelinesNV: flags must not include "
6102 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6103 }
6104 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6105 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6106 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6107 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006108 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6109 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6110 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6111 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6112 }
Peter Chen85366392019-05-14 15:20:11 -04006113 }
6114
6115 return skip;
6116}
6117
sourav parmarcd5fb182020-07-17 12:58:44 -07006118bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6119 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6120 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006121 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006122 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006123 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6124 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6125 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006126 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006127 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006128 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6129 std::stringstream msg;
6130 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6131 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006132 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006133 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006134 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6135 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6136 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6137 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6138 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6139 }
6140 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6141 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6142 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6143 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6144 }
6145 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006146 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006147 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Tony-LunarGce3244a2021-11-19 12:33:40 -07006148 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07006149 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6150 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6151 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006152 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6153 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6154 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006155 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006156 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006157 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6158 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6159 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6160 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006161 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006162 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6163 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6164 }
6165 }
sourav parmarf4a78252020-04-10 13:04:21 -07006166 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006167 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6168 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006169 }
6170 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006171 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006172 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006173 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6174 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006175 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006176 }
6177 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6178 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6179 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006180 }
6181 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6182 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6183 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6184 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6185 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6186 skip |= LogError(
6187 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006188 "vkCreateRayTracingPipelinesKHR: If flags includes "
6189 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006190 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6191 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6192 "must not be VK_SHADER_UNUSED_KHR");
6193 }
6194 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6195 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6196 skip |= LogError(
6197 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006198 "vkCreateRayTracingPipelinesKHR: If flags includes "
6199 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006200 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6201 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6202 "element must not be VK_SHADER_UNUSED_KHR");
6203 }
6204 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006205 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6206 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6207 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6208 skip |= LogError(
6209 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6210 "vkCreateRayTracingPipelinesKHR: If "
6211 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6212 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6213 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6214 }
6215 }
sourav parmarf4a78252020-04-10 13:04:21 -07006216 }
6217 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6218 if (pCreateInfos[i].basePipelineIndex != -1) {
6219 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6220 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006221 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006222 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6223 "and pCreateInfos->basePipelineIndex is not -1.");
6224 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006225 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006226 skip |=
6227 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6228 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6229 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6230 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6231 "element.");
6232 }
sourav parmarf4a78252020-04-10 13:04:21 -07006233 }
6234 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006235 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006236 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006237 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006238 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6239 ") must be a valid into the calling"
6240 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006241 pCreateInfos[i].basePipelineIndex, createInfoCount);
6242 }
6243 } else {
6244 if (pCreateInfos[i].basePipelineIndex != -1) {
6245 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006246 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006247 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6248 }
6249 }
6250 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006251 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6252 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6253 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6254 "vkCreateRayTracingPipelinesKHR: If flags includes "
6255 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6256 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006257 }
6258 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6259 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6260 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6261 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6262 "pLibraryInfo and pLibraryInterface must be NULL.");
6263 }
6264 if (pCreateInfos[i].pLibraryInfo) {
6265 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6266 if (pCreateInfos[i].stageCount == 0) {
6267 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6268 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6269 "stageCount must not be 0.");
6270 }
6271 if (pCreateInfos[i].groupCount == 0) {
6272 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6273 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6274 "groupCount must not be 0.");
6275 }
6276 } else {
6277 if (pCreateInfos[i].pLibraryInterface == NULL) {
6278 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6279 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6280 "is greater than 0, its "
6281 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006282 }
6283 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006284 }
6285 if (pCreateInfos[i].pLibraryInterface) {
6286 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6287 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6288 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6289 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6290 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6291 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006292 }
6293 if (deferredOperation != VK_NULL_HANDLE) {
6294 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6295 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6296 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6297 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006298 }
6299 }
ziga-lunargdea76582021-09-17 14:38:08 +02006300 if (pCreateInfos[i].pDynamicState) {
6301 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6302 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6303 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6304 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6305 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6306 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6307 }
6308 }
6309 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006310 }
6311
6312 return skip;
6313}
6314
Mike Schuchardt21638df2019-03-16 10:52:02 -07006315#ifdef VK_USE_PLATFORM_WIN32_KHR
6316bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6317 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006318 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006319 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006320 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006321 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006322 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006323 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006324 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006325 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006326 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006327 skip |=
6328 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006329 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006330 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6331 skip |= validate_struct_type(
6332 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6333 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6334 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6335 if (pSurfaceInfo != NULL) {
6336 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6337 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6338 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6339
6340 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6341 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6342 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6343 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006344 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6345 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006346
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006347 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6348 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6349 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6350 "VK_GOOGLE_surfaceless_query is not enabled.");
6351 }
6352
Mike Schuchardt21638df2019-03-16 10:52:02 -07006353 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6354 }
6355 return skip;
6356}
6357#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006358
6359bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6360 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006361 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006362 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6363 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006364 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006365 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6366 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6367 }
6368 return skip;
6369}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006370
6371bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006372 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006373 bool skip = false;
6374
6375 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006376 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006377 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006378 }
6379
6380 return skip;
6381}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006382
6383bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006384 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006385 bool skip = false;
6386
6387 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006388 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6389 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006390 }
6391
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006392 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006393 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006394 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6395 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006396 }
6397
6398 return skip;
6399}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006400
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006401bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6402 uint32_t bindingCount, const VkBuffer *pBuffers,
6403 const VkDeviceSize *pOffsets) const {
6404 bool skip = false;
6405 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006406 skip |=
6407 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6408 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6409 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006410 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6411 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006412 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6413 ") must be less than "
6414 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006415 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6416 }
6417
Jeff Bolz165818a2020-05-08 11:19:03 -05006418 for (uint32_t i = 0; i < bindingCount; ++i) {
6419 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006420 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006421 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006422 skip |=
6423 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6424 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006425 } else {
6426 if (pOffsets[i] != 0) {
6427 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006428 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6429 "] is not 0",
6430 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006431 }
6432 }
6433 }
6434 }
6435
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006436 return skip;
6437}
6438
Mark Lobodzinski84988402019-09-11 15:27:30 -06006439bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006440 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006441 bool skip = false;
6442 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006443 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6444 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006445 }
6446 return skip;
6447}
6448
6449bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006450 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006451 bool skip = false;
6452 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006453 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6454 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006455 }
6456 return skip;
6457}
Petr Kraus3d720392019-11-13 02:52:39 +01006458
6459bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6460 VkSemaphore semaphore, VkFence fence,
6461 uint32_t *pImageIndex) const {
6462 bool skip = false;
6463
6464 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006465 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6466 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006467 }
6468
6469 return skip;
6470}
6471
6472bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6473 uint32_t *pImageIndex) const {
6474 bool skip = false;
6475
6476 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006477 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6478 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006479 }
6480
6481 return skip;
6482}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006483
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006484bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6485 uint32_t firstBinding, uint32_t bindingCount,
6486 const VkBuffer *pBuffers,
6487 const VkDeviceSize *pOffsets,
6488 const VkDeviceSize *pSizes) const {
6489 bool skip = false;
6490
6491 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6492 for (uint32_t i = 0; i < bindingCount; ++i) {
6493 if (pOffsets[i] & 3) {
6494 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6495 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6496 }
6497 }
6498
6499 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6500 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6501 "%s: The firstBinding(%" PRIu32
6502 ") index is greater than or equal to "
6503 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6504 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6505 }
6506
6507 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6508 skip |=
6509 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6510 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6511 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6512 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6513 }
6514
6515 for (uint32_t i = 0; i < bindingCount; ++i) {
6516 // pSizes is optional and may be nullptr.
6517 if (pSizes != nullptr) {
6518 if (pSizes[i] != VK_WHOLE_SIZE &&
6519 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6520 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6521 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6522 ") is not VK_WHOLE_SIZE and is greater than "
6523 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6524 cmd_name, i, pSizes[i]);
6525 }
6526 }
6527 }
6528
6529 return skip;
6530}
6531
6532bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6533 uint32_t firstCounterBuffer,
6534 uint32_t counterBufferCount,
6535 const VkBuffer *pCounterBuffers,
6536 const VkDeviceSize *pCounterBufferOffsets) const {
6537 bool skip = false;
6538
6539 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6540 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6541 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6542 "%s: The firstCounterBuffer(%" PRIu32
6543 ") index is greater than or equal to "
6544 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6545 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6546 }
6547
6548 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6549 skip |=
6550 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6551 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6552 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6553 cmd_name, firstCounterBuffer, counterBufferCount,
6554 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6555 }
6556
6557 return skip;
6558}
6559
6560bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6561 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6562 const VkBuffer *pCounterBuffers,
6563 const VkDeviceSize *pCounterBufferOffsets) const {
6564 bool skip = false;
6565
6566 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6567 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6568 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6569 "%s: The firstCounterBuffer(%" PRIu32
6570 ") index is greater than or equal to "
6571 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6572 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6573 }
6574
6575 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6576 skip |=
6577 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6578 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6579 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6580 cmd_name, firstCounterBuffer, counterBufferCount,
6581 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6582 }
6583
6584 return skip;
6585}
6586
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006587bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6588 uint32_t firstInstance, VkBuffer counterBuffer,
6589 VkDeviceSize counterBufferOffset,
6590 uint32_t counterOffset, uint32_t vertexStride) const {
6591 bool skip = false;
6592
6593 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006594 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6595 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6596 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6597 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006598 }
6599
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006600 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006601 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006602 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006603 }
6604
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006605 return skip;
6606}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006607
6608bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6609 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6610 const VkAllocationCallbacks *pAllocator,
6611 VkSamplerYcbcrConversion *pYcbcrConversion,
6612 const char *apiName) const {
6613 bool skip = false;
6614
6615 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006616 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006617 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006618 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006619 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6620 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006621 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006622 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006623 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006624
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006625#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006626 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006627 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006628#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006629 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006630#endif
6631
sfricke-samsung1a72f942020-07-25 12:09:18 -07006632 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006633
6634 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006635 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006636 const VkComponentMapping components = pCreateInfo->components;
6637 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6638 if (FormatIsXChromaSubsampled(format) == true) {
6639 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6640 skip |=
6641 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006642 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6643 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006644 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006645 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006646
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006647 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6648 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6649 skip |= LogError(
6650 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6651 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6652 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6653 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6654 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006655
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006656 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6657 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6658 skip |=
6659 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006660 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6661 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006662 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006663 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006664
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006665 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6666 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6667 skip |=
6668 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006669 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6670 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006671 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006672 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006673
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006674 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006675 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6676 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6677 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006678 skip |=
6679 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006680 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6681 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006682 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6683 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006684 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006685 }
6686
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006687 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6688 // Checks same VU multiple ways in order to give a more useful error message
6689 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6690 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6691 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6692 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6693 skip |= LogError(
6694 device, vuid,
6695 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6696 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6697 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6698 string_VkComponentSwizzle(components.b));
6699 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006700
sfricke-samsunged028b02021-09-06 23:14:51 -07006701 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6702 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006703 // 3 = no [a]
6704 // 2 = no [b,a]
6705 // 1 = no [g,b,a]
6706 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006707 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006708
sfricke-samsunged028b02021-09-06 23:14:51 -07006709 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6710 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006711 skip |= LogError(device, vuid,
6712 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6713 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6714 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6715 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006716 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006717 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6718 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6719 skip |= LogError(device, vuid,
6720 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6721 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6722 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6723 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6724 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006725 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006726 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6727 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6728 skip |= LogError(device, vuid,
6729 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6730 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6731 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6732 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6733 string_VkComponentSwizzle(components.b));
6734 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006735 }
6736 }
6737
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006738 return skip;
6739}
6740
6741bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6742 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6743 const VkAllocationCallbacks *pAllocator,
6744 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6745 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6746 "vkCreateSamplerYcbcrConversion");
6747}
6748
6749bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6750 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6751 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6752 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6753 "vkCreateSamplerYcbcrConversionKHR");
6754}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006755
6756bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6757 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6758 bool skip = false;
6759 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6760 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6761
6762 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006763 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6764 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6765 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6766 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6767 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006768 }
6769 return skip;
6770}
sourav parmara96ab1a2020-04-25 16:28:23 -07006771
6772bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006773 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006774 bool skip = false;
6775 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6776 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6777 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6778 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006779 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006780 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6781 skip |= LogError(
6782 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6783 "vkCopyAccelerationStructureToMemoryKHR: The "
6784 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6785 }
6786 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6787 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6788 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6789 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6790 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6791 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006792 return skip;
6793}
6794
6795bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6796 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6797 bool skip = false;
6798 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6799 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6800 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6801 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6802 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006803 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6804 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006805 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006806 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006807 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006808 return skip;
6809}
6810
6811bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6812 const char *api_name) const {
6813 bool skip = false;
6814 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6815 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6816 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6817 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6818 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6819 api_name);
6820 }
6821 return skip;
6822}
6823
6824bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006825 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006826 bool skip = false;
6827 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006828 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006829 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006830 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006831 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6832 "vkCopyAccelerationStructureKHR: The "
6833 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006834 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006835 return skip;
6836}
6837
6838bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6839 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6840 bool skip = false;
6841 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6842 return skip;
6843}
6844
6845bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006846 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006847 bool skip = false;
6848 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006849 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006850 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6851 }
6852 return skip;
6853}
6854
6855bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006856 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006857 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006858 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006859 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006860 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6861 skip |= LogError(
6862 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6863 "vkCopyMemoryToAccelerationStructureKHR: The "
6864 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006865 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006866 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6867 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006868 return skip;
6869}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006870
sourav parmara96ab1a2020-04-25 16:28:23 -07006871bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6872 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6873 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006874 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006875 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6876 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006877 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006878 pInfo->src.deviceAddress);
6879 }
sourav parmar83c31b12020-05-06 12:30:54 -07006880 return skip;
6881}
6882bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6883 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6884 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6885 bool skip = false;
6886 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6887 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6888 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6889 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6890 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6891 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6892 }
6893 return skip;
6894}
6895bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6896 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6897 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6898 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006899 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006900 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6901 skip |= LogError(
6902 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6903 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6904 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6905 }
sourav parmar83c31b12020-05-06 12:30:54 -07006906 if (dataSize < accelerationStructureCount * stride) {
6907 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6908 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006909 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006910 dataSize, accelerationStructureCount, stride);
6911 }
6912 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6913 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6914 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6915 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6916 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6917 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6918 }
6919 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6920 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6921 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6922 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6923 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6924 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6925 stride);
6926 }
6927 }
6928 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6929 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6930 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6931 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6932 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6933 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6934 stride);
6935 }
6936 }
sourav parmar83c31b12020-05-06 12:30:54 -07006937 return skip;
6938}
6939bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6940 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6941 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006942 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006943 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6944 skip |= LogError(
6945 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6946 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6947 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006948 }
6949 return skip;
6950}
6951
6952bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006953 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6954 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6955 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6956 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006957 uint32_t width, uint32_t height, uint32_t depth) const {
6958 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006959 // RayGen
6960 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6961 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6962 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006963 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006964 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6965 0) {
6966 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6967 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6968 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6969 }
6970 // Callable
6971 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6972 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6973 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6974 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006975 }
6976 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6977 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6978 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006979 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6980 }
6981 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6982 0) {
6983 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6984 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6985 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006986 }
6987 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006988 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6989 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6990 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6991 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006992 }
6993 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6994 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006995 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6996 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006997 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006998 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6999 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7000 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7001 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7002 }
sourav parmar83c31b12020-05-06 12:30:54 -07007003 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007004 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7005 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7006 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7007 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007008 }
7009 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7010 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7011 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007012 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7013 }
7014 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7015 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7016 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7017 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7018 }
7019 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
7020 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
7021 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7022 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7023 }
7024 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7025 skip |=
7026 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
7027 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7028 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007029 }
7030
sourav parmarcd5fb182020-07-17 12:58:44 -07007031 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7032 skip |=
7033 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
7034 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7035 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7036 }
7037
7038 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7039 skip |=
7040 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
7041 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7042 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007043 }
7044 return skip;
7045}
7046
sourav parmarcd5fb182020-07-17 12:58:44 -07007047bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7048 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7049 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7050 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007051 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007052 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007053 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7054 skip |= LogError(
7055 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7056 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7057 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007058 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007059 // RayGen
7060 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7061 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7062 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007063 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007064 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7065 0) {
7066 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7067 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7068 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7069 }
7070 // Callabe
7071 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7072 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7073 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7074 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007075 }
7076 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7077 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007078 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7079 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7080 }
7081 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7082 0) {
7083 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7084 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7085 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007086 }
7087 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007088 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7089 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7090 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7091 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007092 }
7093 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7094 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007095 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7096 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007097 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007098 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7099 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7100 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7101 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7102 }
sourav parmar83c31b12020-05-06 12:30:54 -07007103 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007104 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7105 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7106 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7107 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007108 }
7109 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7110 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007111 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7112 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7113 }
7114 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7115 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7116 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7117 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007118 }
7119
sourav parmarcd5fb182020-07-17 12:58:44 -07007120 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7121 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7122 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007123 }
7124 return skip;
7125}
7126bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7127 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7128 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7129 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7130 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7131 uint32_t width, uint32_t height, uint32_t depth) const {
7132 bool skip = false;
7133 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7134 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7135 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7136 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7137 }
7138 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7139 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7140 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7141 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7142 }
7143 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7144 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7145 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7146 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7147 }
7148
7149 // hitShader
7150 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7151 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7152 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7153 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7154 }
7155 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7156 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7157 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7158 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7159 }
7160 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7161 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7162 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7163 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7164 }
7165
7166 // missShader
7167 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7168 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7169 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7170 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7171 }
7172 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7173 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7174 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7175 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7176 }
7177 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7178 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7179 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7180 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7181 }
7182
7183 // raygenShader
7184 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7185 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7186 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007187 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7188 }
7189 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7190 skip |=
7191 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7192 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7193 }
7194 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7195 skip |=
7196 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7197 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7198 }
7199 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7200 skip |=
7201 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7202 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007203 }
7204 return skip;
7205}
7206
sourav parmar83c31b12020-05-06 12:30:54 -07007207bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007208 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7209 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007210 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007211 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7212 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007213 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7214 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007215 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007216 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7217 }
7218 return skip;
7219}
7220
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007221bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7222 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007223 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007224 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007225
7226 if (!physical_device_features.multiViewport) {
7227 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007228 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7229 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007230 viewportCount);
7231 }
7232 } else { // multiViewport enabled
7233 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007234 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7235 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007236 ") must "
7237 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007238 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007239 }
7240 }
7241
7242 if (pViewports) {
7243 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7244 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007245 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007246 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007247 }
7248 }
7249
7250 return skip;
7251}
7252
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007253bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7254 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007255 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007256 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7257 return skip;
7258}
7259
7260bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7261 const VkViewport *pViewports) const {
7262 bool skip = false;
7263 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7264 return skip;
7265}
7266
7267bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7268 const VkRect2D *pScissors, bool is_ext) const {
7269 bool skip = false;
7270 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007271
7272 if (!physical_device_features.multiViewport) {
7273 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007274 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7275 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007276 ") must "
7277 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007278 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007279 }
7280 } else { // multiViewport enabled
7281 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007282 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7283 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007284 ") must "
7285 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007286 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007287 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007288 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7289 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007290 ") must "
7291 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007292 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007293 }
7294 }
7295
7296 if (pScissors) {
7297 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7298 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7299
7300 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007301 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7302 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007303 }
7304
7305 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007306 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7307 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007308 }
7309
7310 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7311 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007312 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7313 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7314 "] will overflow int32_t.",
7315 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007316 }
7317
7318 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7319 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007320 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7321 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7322 "] will overflow int32_t.",
7323 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7324 }
7325 }
7326 }
7327
7328 return skip;
7329}
7330
7331bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7332 const VkRect2D *pScissors) const {
7333 bool skip = false;
7334 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7335 return skip;
7336}
7337
7338bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7339 const VkRect2D *pScissors) const {
7340 bool skip = false;
7341 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7342 return skip;
7343}
7344
7345bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7346 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7347 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7348 bool is_2ext) const {
7349 bool skip = false;
7350 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7351 if (firstBinding >= device_limits.maxVertexInputBindings) {
7352 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7353 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7354 firstBinding, device_limits.maxVertexInputBindings);
7355 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7356 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7357 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7358 ") must be less than "
7359 "maxVertexInputBindings (%" PRIu32 ")",
7360 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7361 }
7362
7363 for (uint32_t i = 0; i < bindingCount; ++i) {
7364 if (pBuffers[i] == VK_NULL_HANDLE) {
7365 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7366 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7367 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7368 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7369 } else {
7370 if (pOffsets[i] != 0) {
7371 skip |=
7372 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7373 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7374 }
7375 }
7376 }
7377 if (pStrides) {
7378 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7379 skip |=
7380 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7381 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7382 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007383 }
7384 }
7385 }
7386
7387 return skip;
7388}
7389
7390bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7391 uint32_t bindingCount, const VkBuffer *pBuffers,
7392 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7393 const VkDeviceSize *pStrides) const {
7394 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007395 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7396 return skip;
7397}
Piers Daniell39842ee2020-07-10 16:42:33 -06007398
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007399bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7400 uint32_t bindingCount, const VkBuffer *pBuffers,
7401 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7402 const VkDeviceSize *pStrides) const {
7403 bool skip = false;
7404 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007405 return skip;
7406}
sourav parmarcd5fb182020-07-17 12:58:44 -07007407
7408bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7409 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7410 bool skip = false;
7411 for (uint32_t i = 0; i < infoCount; ++i) {
7412 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7413 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7414 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7415 }
7416 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7417 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7418 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7419 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7420 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7421 api_name);
7422 }
7423 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7424 skip |=
7425 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7426 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7427 }
7428 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7429 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7430 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7431 }
7432 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7433 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7434 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7435 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7436 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7437 api_name);
7438 }
7439 if (pInfos[i].pGeometries) {
7440 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7441 skip |= validate_ranged_enum(
7442 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7443 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7444 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7445 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007446 skip |= validate_struct_type(
7447 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7448 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7449 &(pInfos[i].pGeometries[j].geometry.triangles),
7450 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7451 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7452 skip |= validate_struct_pnext(
7453 api_name,
7454 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7455 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7456 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7457 skip |=
7458 validate_ranged_enum(api_name,
7459 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7460 ParameterName::IndexVector{i, j}),
7461 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7462 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7463 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7464 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7465 &pInfos[i].pGeometries[j].geometry.triangles,
7466 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7467 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7468 skip |= validate_ranged_enum(
7469 api_name,
7470 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7471 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7472 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7473
7474 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7475 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7476 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7477 }
7478 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7479 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7480 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7481 skip |=
7482 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7483 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7484 api_name);
7485 }
7486 }
7487 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7488 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7489 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7490 &pInfos[i].pGeometries[j].geometry.instances,
7491 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7492 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7493 skip |= validate_struct_type(
7494 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7495 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7496 &(pInfos[i].pGeometries[j].geometry.instances),
7497 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7498 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7499 skip |= validate_struct_pnext(
7500 api_name,
7501 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7502 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7503 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7504
7505 skip |= validate_bool32(api_name,
7506 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7507 ParameterName::IndexVector{i, j}),
7508 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7509 }
7510 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7511 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7512 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7513 &pInfos[i].pGeometries[j].geometry.aabbs,
7514 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7515 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7516 skip |= validate_struct_type(
7517 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7518 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7519 &(pInfos[i].pGeometries[j].geometry.aabbs),
7520 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7521 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7522 skip |= validate_struct_pnext(
7523 api_name,
7524 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7525 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7526 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7527 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7528 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7529 "(%s):stride must be less than or equal to 2^32-1", api_name);
7530 }
7531 }
7532 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7533 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7534 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7535 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7536 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7537 api_name);
7538 }
7539 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7540 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7541 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7542 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7543 "of elements of"
7544 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7545 api_name);
7546 }
7547 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7548 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7549 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7550 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7551 api_name);
7552 }
7553 }
7554 }
7555 }
7556 if (pInfos[i].ppGeometries != NULL) {
7557 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7558 skip |= validate_ranged_enum(
7559 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7560 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7561 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7562 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007563 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7564 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7565 &pInfos[i].ppGeometries[j]->geometry.triangles,
7566 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7567 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7568 skip |= validate_struct_type(
7569 api_name,
7570 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7571 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7572 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7573 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7574 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7575 skip |= validate_struct_pnext(
7576 api_name,
7577 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7578 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7579 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7580 skip |= validate_ranged_enum(api_name,
7581 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7582 ParameterName::IndexVector{i, j}),
7583 "VkFormat", AllVkFormatEnums,
7584 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7585 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7586 skip |= validate_ranged_enum(api_name,
7587 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7588 ParameterName::IndexVector{i, j}),
7589 "VkIndexType", AllVkIndexTypeEnums,
7590 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7591 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7592 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7593 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7594 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7595 }
7596 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7597 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7598 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7599 skip |=
7600 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7601 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7602 api_name);
7603 }
7604 }
7605 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7606 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7607 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7608 &pInfos[i].ppGeometries[j]->geometry.instances,
7609 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7610 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7611 skip |= validate_struct_type(
7612 api_name,
7613 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7614 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7615 &(pInfos[i].ppGeometries[j]->geometry.instances),
7616 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7617 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7618 skip |= validate_struct_pnext(
7619 api_name,
7620 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7621 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7622 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7623 skip |= validate_bool32(api_name,
7624 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7625 ParameterName::IndexVector{i, j}),
7626 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7627 }
7628 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7629 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7630 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7631 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7632 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7633 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7634 skip |= validate_struct_type(
7635 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7636 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7637 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7638 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7639 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7640 skip |= validate_struct_pnext(
7641 api_name,
7642 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7643 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7644 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7645 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7646 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7647 "(%s):stride must be less than or equal to 2^32-1", api_name);
7648 }
7649 }
7650 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7651 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7652 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7653 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7654 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7655 api_name);
7656 }
7657 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7658 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7659 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7660 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7661 "of elements of"
7662 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7663 api_name);
7664 }
7665 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7666 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7667 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7668 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7669 api_name);
7670 }
7671 }
7672 }
7673 }
7674 }
7675 return skip;
7676}
7677bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7678 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7679 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7680 bool skip = false;
7681 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7682 for (uint32_t i = 0; i < infoCount; ++i) {
7683 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7684 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7685 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7686 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7687 "scratchData.deviceAddress member must be a multiple of "
7688 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7689 }
7690 for (uint32_t k = 0; k < infoCount; ++k) {
7691 if (i == k) continue;
7692 bool found = false;
7693 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007694 skip |=
7695 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7696 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7697 ") of pInfos must "
7698 "not be "
7699 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7700 ") of pInfos.",
7701 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007702 found = true;
7703 }
7704 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007705 skip |=
7706 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7707 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7708 ") of pInfos must "
7709 "not be "
7710 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7711 ") of pInfos.",
7712 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007713 found = true;
7714 }
7715 if (found) break;
7716 }
7717 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7718 if (pInfos[i].pGeometries) {
7719 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7720 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7721 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7722 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7723 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7724 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7725 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7726 }
7727 } else {
7728 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7729 skip |=
7730 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7731 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7732 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7733 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7734 }
7735 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007736 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007737 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7738 skip |= LogError(
7739 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7740 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7741 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7742 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007743 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7744 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007745 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7746 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7747 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7748 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7749 }
7750 }
7751 } else if (pInfos[i].ppGeometries) {
7752 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7753 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7754 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7755 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7756 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7757 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7758 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7759 }
7760 } else {
7761 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7762 skip |=
7763 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7764 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7765 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7766 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7767 }
7768 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007769 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007770 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7771 skip |= LogError(
7772 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7773 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7774 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7775 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007776 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7777 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007778 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7779 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7780 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7781 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7782 }
7783 }
7784 }
7785 }
7786 }
7787 return skip;
7788}
7789
7790bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7791 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7792 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7793 const uint32_t *const *ppMaxPrimitiveCounts) const {
7794 bool skip = false;
7795 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7796 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007797 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007798 if (!ray_tracing_acceleration_structure_features ||
7799 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7800 skip |= LogError(
7801 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7802 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7803 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7804 }
7805 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007806 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7807 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7808 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7809 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7810 "scratchData.deviceAddress member must be a multiple of "
7811 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7812 }
7813 for (uint32_t k = 0; k < infoCount; ++k) {
7814 if (i == k) continue;
7815 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007816 skip |= LogError(
7817 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7818 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7819 ") "
7820 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7821 "any other element [%" PRIu32 ") of pInfos.",
7822 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007823 break;
7824 }
7825 }
7826 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7827 if (pInfos[i].pGeometries) {
7828 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7829 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7830 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7831 skip |= LogError(
7832 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7833 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7834 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7835 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7836 }
7837 } else {
7838 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7839 skip |= LogError(
7840 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7841 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7842 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7843 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7844 }
7845 }
7846 }
7847 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7848 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7849 skip |= LogError(
7850 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7851 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7852 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7853 }
7854 }
7855 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7856 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7857 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7858 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7859 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7860 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7861 }
7862 }
7863 } else if (pInfos[i].ppGeometries) {
7864 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7865 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7866 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7867 skip |= LogError(
7868 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7869 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7870 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7871 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7872 }
7873 } else {
7874 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7875 skip |= LogError(
7876 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7877 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7878 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7879 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7880 }
7881 }
7882 }
7883 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7884 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7885 skip |= LogError(
7886 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7887 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7888 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7889 }
7890 }
7891 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7892 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7893 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7894 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7895 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7896 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7897 }
7898 }
7899 }
7900 }
7901 }
7902 return skip;
7903}
7904
7905bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7906 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7907 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7908 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7909 bool skip = false;
7910 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7911 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007912 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007913 if (!ray_tracing_acceleration_structure_features ||
7914 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7915 skip |=
7916 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7917 "vkBuildAccelerationStructuresKHR: The "
7918 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7919 }
7920 for (uint32_t i = 0; i < infoCount; ++i) {
7921 for (uint32_t j = 0; j < infoCount; ++j) {
7922 if (i == j) continue;
7923 bool found = false;
7924 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007925 skip |=
7926 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7927 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
7928 ") of pInfos must "
7929 "not be "
7930 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7931 ") of pInfos.",
7932 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007933 found = true;
7934 }
7935 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007936 skip |=
7937 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7938 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
7939 ") of pInfos must "
7940 "not be "
7941 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7942 ") of pInfos.",
7943 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007944 found = true;
7945 }
7946 if (found) break;
7947 }
7948 }
7949 return skip;
7950}
7951
7952bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7953 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7954 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7955 bool skip = false;
7956 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7957 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007958 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7959 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01007960 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
7961 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007962 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01007963 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
7964 }
7965 if (pBuildInfo != nullptr) {
7966 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
7967 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
7968 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
7969 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
7970 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007971 }
7972 return skip;
7973}
sfricke-samsungecafb192021-01-17 08:21:14 -08007974
Piers Daniellcb6d8032021-04-19 18:51:26 -06007975bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7976 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7977 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7978 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7979 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06007980 const auto *vertex_attribute_divisor_features =
7981 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7982
Piers Daniellcb6d8032021-04-19 18:51:26 -06007983 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7984 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7985 skip |=
7986 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7987 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7988 }
7989
7990 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7991 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7992 skip |= LogError(
7993 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7994 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7995 }
7996
7997 // VUID-vkCmdSetVertexInputEXT-binding-04793
7998 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7999 bool binding_found = false;
8000 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8001 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8002 binding_found = true;
8003 break;
8004 }
8005 }
8006 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008007 skip |= LogError(
8008 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8009 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008010 }
8011 }
8012
8013 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8014 if (vertexBindingDescriptionCount > 1) {
8015 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8016 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8017 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8018 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8019 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008020 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8021 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008022 }
8023 }
8024 }
8025 }
8026
8027 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8028 if (vertexAttributeDescriptionCount > 1) {
8029 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8030 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8031 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8032 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8033 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008034 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8035 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008036 }
8037 }
8038 }
8039 }
8040
8041 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8042 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8043 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008044 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8045 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8046 "].binding is greater than maxVertexInputBindings",
8047 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008048 }
8049
8050 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8051 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008052 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8053 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8054 "].stride is greater than maxVertexInputBindingStride",
8055 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008056 }
8057
8058 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8059 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8060 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8061 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008062 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8063 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008064 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8065 binding);
8066 }
8067
8068 if (pVertexBindingDescriptions[binding].divisor > 1) {
8069 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8070 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8071 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008072 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8073 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008074 "vertexAttributeInstanceRateDivisor is not enabled",
8075 binding);
8076 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008077 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008078 if (pVertexBindingDescriptions[binding].divisor >
8079 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008080 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8081 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8082 "].divisor is greater than maxVertexAttribDivisor",
8083 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008084 }
8085
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008086 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008087 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008088 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8089 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8090 "].divisor is greater than 1 but inputRate "
8091 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8092 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008093 }
8094 }
8095 }
8096 }
8097
8098 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008099 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008100 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008101 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8102 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8103 "].location is greater than maxVertexInputAttributes",
8104 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008105 }
8106
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008107 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008108 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008109 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8110 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8111 "].binding is greater than maxVertexInputBindings",
8112 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008113 }
8114
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008115 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008116 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008117 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8118 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8119 "].offset is greater than maxVertexInputAttributeOffset",
8120 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008121 }
8122
8123 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8124 VkFormatProperties properties;
8125 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8126 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8127 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008128 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8129 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008130 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8131 attribute);
8132 }
8133 }
8134
8135 return skip;
8136}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008137
8138bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8139 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8140 const void *pValues) const {
8141 bool skip = false;
8142 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8143 // Check that offset + size don't exceed the max.
8144 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8145 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008146 skip |=
8147 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8148 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8149 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008150 }
8151 if (size > max_push_constants_size - offset) {
8152 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008153 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8154 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008155 offset, size, max_push_constants_size);
8156 }
8157
8158 // size needs to be non-zero and a multiple of 4.
8159 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008160 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8161 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008162 }
8163
8164 // offset needs to be a multiple of 4.
8165 if ((offset & 0x3) != 0) {
8166 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008167 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008168 }
8169 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008170}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008171
8172bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8173 uint32_t srcCacheCount,
8174 const VkPipelineCache *pSrcCaches) const {
8175 bool skip = false;
8176 if (pSrcCaches) {
8177 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8178 if (pSrcCaches[index0] == dstCache) {
8179 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8180 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8181 report_data->FormatHandle(dstCache).c_str());
8182 break;
8183 }
8184 }
8185 }
8186 return skip;
8187}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008188
8189bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8190 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8191 uint32_t rangeCount,
8192 const VkImageSubresourceRange *pRanges) const {
8193 bool skip = false;
8194 if (!pColor) {
8195 skip |=
8196 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8197 }
8198 return skip;
8199}
8200
8201bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8202 const VkRenderPassBeginInfo *const rp_begin) const {
8203 bool skip = false;
8204 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8205 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8206 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008207 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008208 func_name, rp_begin->clearValueCount);
8209 }
8210 return skip;
8211}
8212
8213bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8214 VkSubpassContents) const {
8215 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8216 return skip;
8217}
8218
8219bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8220 const VkRenderPassBeginInfo *pRenderPassBegin,
8221 const VkSubpassBeginInfo *) const {
8222 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8223 return skip;
8224}
8225
8226bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8227 const VkSubpassBeginInfo *) const {
8228 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8229 return skip;
8230}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008231
8232bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8233 uint32_t firstDiscardRectangle,
8234 uint32_t discardRectangleCount,
8235 const VkRect2D *pDiscardRectangles) const {
8236 bool skip = false;
8237
8238 if (pDiscardRectangles) {
8239 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8240 const int64_t x_sum =
8241 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8242 if (x_sum > std::numeric_limits<int32_t>::max()) {
8243 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8244 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8245 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8246 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8247 }
8248
8249 const int64_t y_sum =
8250 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8251 if (y_sum > std::numeric_limits<int32_t>::max()) {
8252 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8253 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8254 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8255 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8256 }
8257 }
8258 }
8259
8260 return skip;
8261}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008262
8263bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8264 uint32_t queryCount, size_t dataSize, void *pData,
8265 VkDeviceSize stride, VkQueryResultFlags flags) const {
8266 bool skip = false;
8267
8268 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8269 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8270 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8271 }
8272
8273 return skip;
8274}
ziga-lunargcf340c42021-08-19 00:13:38 +02008275
8276bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8277 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8278 bool skip = false;
8279
8280 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8281 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8282 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8283 ") is not a multiple of 4.",
8284 pConditionalRenderingBegin->offset);
8285 }
8286
8287 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008288}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008289
8290bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8291 VkSurfaceKHR surface,
8292 uint32_t *pSurfaceFormatCount,
8293 VkSurfaceFormatKHR *pSurfaceFormats) const {
8294 bool skip = false;
8295 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8296 skip |= LogError(
8297 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8298 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8299 }
8300 return skip;
8301}
8302
8303bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8304 VkSurfaceKHR surface,
8305 uint32_t *pPresentModeCount,
8306 VkPresentModeKHR *pPresentModes) const {
8307 bool skip = false;
8308 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8309 skip |= LogError(
8310 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8311 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8312 }
8313 return skip;
8314}
8315
8316bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8317 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8318 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8319 bool skip = false;
8320 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8321 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8322 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8323 "VK_GOOGLE_surfaceless_query is not enabled.");
8324 }
8325 return skip;
8326}
8327
8328bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8329 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8330 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8331 bool skip = false;
8332 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8333 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8334 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8335 "VK_GOOGLE_surfaceless_query is not enabled.");
8336 }
8337 return skip;
8338}
8339
8340#ifdef VK_USE_PLATFORM_WIN32_KHR
8341bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8342 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8343 VkPresentModeKHR *pPresentModes) const {
8344 bool skip = false;
8345 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8346 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8347 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8348 "VK_GOOGLE_surfaceless_query is not enabled.");
8349 }
8350 return skip;
8351}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008352
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008353#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008354
8355bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8356 const char *func_name) const {
8357 bool skip = false;
8358
8359 if (pInfo && pInfo->pCreateInfo) {
8360 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8361 if (image_swapchain_create_info) {
8362 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8363 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8364 }
8365 }
8366
8367 return skip;
8368}
8369
8370bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8371 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8372 bool skip = false;
8373
8374 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8375
8376 return skip;
8377}
8378
8379bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8380 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8381 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8382 bool skip = false;
8383
8384 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8385
8386 return skip;
8387}