blob: 0d5b08c6b5c6a1bcefa2c56622e91c83862e1c11 [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
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001607 const bool has_independent_sets = (pCreateInfo->flags & VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT) != 0;
1608 const bool graphics_pipeline_library = IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library);
1609 const char *const valid_dsl_vuid = (!graphics_pipeline_library)
1610 ? "VUID-VkPipelineLayoutCreateInfo-pSetLayouts-06561"
1611 : ((!has_independent_sets) ? "VUID-VkPipelineLayoutCreateInfo-flags-06562" : nullptr);
1612 if (valid_dsl_vuid) {
1613 for (uint32_t i = 0; i < pCreateInfo->setLayoutCount; ++i) {
1614 if (!pCreateInfo->pSetLayouts[i]) {
1615 skip |=
1616 LogError(device, valid_dsl_vuid, "vkCreatePipelineLayout(): pSetLayouts[%" PRIu32 "] is VK_NULL_HANDLE.", i);
1617 }
1618 }
1619 }
1620
sfricke-samsung51303fb2021-05-09 19:09:13 -07001621 // Validate Push Constant ranges
1622 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1623 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1624 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1625 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1626 // Check that offset + size don't exceed the max.
1627 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1628 if (offset >= max_push_constants_size) {
1629 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001630 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1631 ") that exceeds this "
1632 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001633 i, offset, max_push_constants_size);
1634 }
1635 if (size > max_push_constants_size - offset) {
1636 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001637 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1638 ") and size (%" PRIu32
1639 ") "
1640 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001641 i, offset, size, max_push_constants_size);
1642 }
1643
1644 // size needs to be non-zero and a multiple of 4.
1645 if (size == 0) {
1646 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001647 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1648 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001649 i, size);
1650 }
1651 if (size & 0x3) {
1652 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001653 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1654 ") is not a multiple of 4.",
1655 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001656 }
1657
1658 // offset needs to be a multiple of 4.
1659 if ((offset & 0x3) != 0) {
1660 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001661 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1662 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001663 i, offset);
1664 }
1665 }
1666
1667 // 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.
1668 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1669 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1670 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001671 skip |=
1672 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1673 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001674 }
1675 }
1676 }
1677 return skip;
1678}
1679
ziga-lunargc6341372021-07-28 12:57:42 +02001680bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1681 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1682 bool skip = false;
1683
1684 const auto *required_subgroup_size_features =
1685 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1686
1687 if (required_subgroup_size_features) {
1688 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1689 skip |= LogError(
1690 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1691 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1692 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1693 func_name, msg, pCreateInfo->flags);
1694 }
1695 }
1696
1697 return skip;
1698}
1699
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001700bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1701 uint32_t createInfoCount,
1702 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1703 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001704 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001705 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001706
1707 if (pCreateInfos != nullptr) {
1708 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001709 bool has_dynamic_viewport = false;
1710 bool has_dynamic_scissor = false;
1711 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001712 bool has_dynamic_depth_bias = false;
1713 bool has_dynamic_blend_constant = false;
1714 bool has_dynamic_depth_bounds = false;
1715 bool has_dynamic_stencil_compare = false;
1716 bool has_dynamic_stencil_write = false;
1717 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001718 bool has_dynamic_viewport_w_scaling_nv = false;
1719 bool has_dynamic_discard_rectangle_ext = false;
1720 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001721 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001722 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001723 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001724 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001725 bool has_dynamic_cull_mode = false;
1726 bool has_dynamic_front_face = false;
1727 bool has_dynamic_primitive_topology = false;
1728 bool has_dynamic_viewport_with_count = false;
1729 bool has_dynamic_scissor_with_count = false;
1730 bool has_dynamic_vertex_input_binding_stride = false;
1731 bool has_dynamic_depth_test_enable = false;
1732 bool has_dynamic_depth_write_enable = false;
1733 bool has_dynamic_depth_compare_op = false;
1734 bool has_dynamic_depth_bounds_test_enable = false;
1735 bool has_dynamic_stencil_test_enable = false;
1736 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001737 bool has_patch_control_points = false;
1738 bool has_rasterizer_discard_enable = false;
1739 bool has_depth_bias_enable = false;
1740 bool has_logic_op = false;
1741 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001742 bool has_dynamic_vertex_input = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001743
1744 // Create a copy of create_info and set non-included sub-state to null
1745 auto create_info = pCreateInfos[i];
1746 const auto *graphics_lib_info = LvlFindInChain<VkGraphicsPipelineLibraryCreateInfoEXT>(create_info.pNext);
1747 if (graphics_lib_info) {
1748 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT)) {
1749 create_info.pVertexInputState = nullptr;
1750 create_info.pInputAssemblyState = nullptr;
1751 }
1752 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT)) {
1753 create_info.pViewportState = nullptr;
1754 create_info.pRasterizationState = nullptr;
1755 create_info.pTessellationState = nullptr;
1756 }
1757 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT)) {
1758 create_info.pDepthStencilState = nullptr;
1759 }
1760 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) {
1761 create_info.pColorBlendState = nullptr;
1762 }
1763 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1764 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1765 create_info.pMultisampleState = nullptr;
1766 }
1767 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1768 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT))) {
1769 create_info.layout = VK_NULL_HANDLE;
1770 }
1771 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1772 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1773 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1774 create_info.renderPass = VK_NULL_HANDLE;
1775 create_info.subpass = 0;
1776 }
1777 }
1778
1779 // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline"
1780 if (create_info.pDynamicState != nullptr) {
1781 const auto &dynamic_state_info = *create_info.pDynamicState;
Petr Kraus299ba622017-11-24 03:09:03 +01001782 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1783 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001784 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1785 if (has_dynamic_viewport == true) {
1786 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1787 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001788 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001789 i);
1790 }
1791 has_dynamic_viewport = true;
1792 }
1793 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1794 if (has_dynamic_scissor == true) {
1795 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1796 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001797 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001798 i);
1799 }
1800 has_dynamic_scissor = true;
1801 }
1802 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1803 if (has_dynamic_line_width == true) {
1804 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1805 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001806 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001807 i);
1808 }
1809 has_dynamic_line_width = true;
1810 }
1811 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1812 if (has_dynamic_depth_bias == true) {
1813 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1814 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001815 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001816 i);
1817 }
1818 has_dynamic_depth_bias = true;
1819 }
1820 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1821 if (has_dynamic_blend_constant == true) {
1822 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1823 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001824 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001825 i);
1826 }
1827 has_dynamic_blend_constant = true;
1828 }
1829 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1830 if (has_dynamic_depth_bounds == true) {
1831 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1832 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001833 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001834 i);
1835 }
1836 has_dynamic_depth_bounds = true;
1837 }
1838 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1839 if (has_dynamic_stencil_compare == true) {
1840 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1841 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001842 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001843 i);
1844 }
1845 has_dynamic_stencil_compare = true;
1846 }
1847 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1848 if (has_dynamic_stencil_write == true) {
1849 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1850 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001851 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001852 i);
1853 }
1854 has_dynamic_stencil_write = true;
1855 }
1856 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1857 if (has_dynamic_stencil_reference == true) {
1858 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1859 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001860 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001861 i);
1862 }
1863 has_dynamic_stencil_reference = true;
1864 }
1865 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1866 if (has_dynamic_viewport_w_scaling_nv == true) {
1867 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1868 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001869 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001870 i);
1871 }
1872 has_dynamic_viewport_w_scaling_nv = true;
1873 }
1874 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1875 if (has_dynamic_discard_rectangle_ext == true) {
1876 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1877 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001878 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001879 i);
1880 }
1881 has_dynamic_discard_rectangle_ext = true;
1882 }
1883 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1884 if (has_dynamic_sample_locations_ext == true) {
1885 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1886 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001887 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001888 i);
1889 }
1890 has_dynamic_sample_locations_ext = true;
1891 }
1892 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1893 if (has_dynamic_exclusive_scissor_nv == true) {
1894 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1895 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001896 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001897 i);
1898 }
1899 has_dynamic_exclusive_scissor_nv = true;
1900 }
1901 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1902 if (has_dynamic_shading_rate_palette_nv == true) {
1903 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1904 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001905 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001906 i);
1907 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001908 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001909 }
1910 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1911 if (has_dynamic_viewport_course_sample_order_nv == true) {
1912 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1913 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001914 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001915 i);
1916 }
1917 has_dynamic_viewport_course_sample_order_nv = true;
1918 }
1919 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1920 if (has_dynamic_line_stipple == true) {
1921 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1922 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001923 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001924 i);
1925 }
1926 has_dynamic_line_stipple = true;
1927 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001928 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1929 if (has_dynamic_cull_mode) {
1930 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1931 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001932 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001933 i);
1934 }
1935 has_dynamic_cull_mode = true;
1936 }
1937 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1938 if (has_dynamic_front_face) {
1939 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1940 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001941 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001942 i);
1943 }
1944 has_dynamic_front_face = true;
1945 }
1946 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1947 if (has_dynamic_primitive_topology) {
1948 skip |= LogError(
1949 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1950 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001951 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001952 i);
1953 }
1954 has_dynamic_primitive_topology = true;
1955 }
1956 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1957 if (has_dynamic_viewport_with_count) {
1958 skip |= LogError(
1959 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1960 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001961 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001962 i);
1963 }
1964 has_dynamic_viewport_with_count = true;
1965 }
1966 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1967 if (has_dynamic_scissor_with_count) {
1968 skip |= LogError(
1969 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1970 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001971 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001972 i);
1973 }
1974 has_dynamic_scissor_with_count = true;
1975 }
1976 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1977 if (has_dynamic_vertex_input_binding_stride) {
1978 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1979 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1980 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001981 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001982 i);
1983 }
1984 has_dynamic_vertex_input_binding_stride = true;
1985 }
1986 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1987 if (has_dynamic_depth_test_enable) {
1988 skip |= LogError(
1989 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1990 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001991 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001992 i);
1993 }
1994 has_dynamic_depth_test_enable = true;
1995 }
1996 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1997 if (has_dynamic_depth_write_enable) {
1998 skip |= LogError(
1999 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2000 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002001 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002002 i);
2003 }
2004 has_dynamic_depth_write_enable = true;
2005 }
2006 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
2007 if (has_dynamic_depth_compare_op) {
2008 skip |=
2009 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2010 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002011 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002012 i);
2013 }
2014 has_dynamic_depth_compare_op = true;
2015 }
2016 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
2017 if (has_dynamic_depth_bounds_test_enable) {
2018 skip |= LogError(
2019 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2020 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002021 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002022 i);
2023 }
2024 has_dynamic_depth_bounds_test_enable = true;
2025 }
2026 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
2027 if (has_dynamic_stencil_test_enable) {
2028 skip |= LogError(
2029 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2030 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002031 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002032 i);
2033 }
2034 has_dynamic_stencil_test_enable = true;
2035 }
2036 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
2037 if (has_dynamic_stencil_op) {
2038 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2039 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002040 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002041 i);
2042 }
2043 has_dynamic_stencil_op = true;
2044 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002045 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
2046 // Not allowed for graphics pipelines
2047 skip |= LogError(
2048 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
2049 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002050 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
2051 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002052 i, state_index);
2053 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002054 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
2055 if (has_patch_control_points) {
2056 skip |= LogError(
2057 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2058 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002059 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002060 i);
2061 }
2062 has_patch_control_points = true;
2063 }
2064 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2065 if (has_rasterizer_discard_enable) {
2066 skip |= LogError(
2067 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2068 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002069 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002070 i);
2071 }
2072 has_rasterizer_discard_enable = true;
2073 }
2074 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2075 if (has_depth_bias_enable) {
2076 skip |= LogError(
2077 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2078 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002079 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002080 i);
2081 }
2082 has_depth_bias_enable = true;
2083 }
2084 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2085 if (has_logic_op) {
2086 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2087 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002088 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002089 i);
2090 }
2091 has_logic_op = true;
2092 }
2093 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2094 if (has_primitive_restart_enable) {
2095 skip |= LogError(
2096 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2097 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002098 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002099 i);
2100 }
2101 has_primitive_restart_enable = true;
2102 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002103 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2104 if (has_dynamic_vertex_input) {
2105 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002106 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2107 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2108 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002109 }
2110 has_dynamic_vertex_input = true;
2111 }
Petr Kraus299ba622017-11-24 03:09:03 +01002112 }
2113 }
2114
sfricke-samsung3b944422021-01-23 02:15:19 -08002115 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2116 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2117 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002118 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2119 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002120 i);
2121 }
2122
2123 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2124 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2125 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002126 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002127 i);
2128 }
2129
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002130 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext);
2131 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) {
Tony-LunarGce3244a2021-11-19 12:33:40 -07002132 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02668",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002133 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2134 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2135 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002136 i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002137 }
2138
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002139 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002140
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002141 // Collect active stages and other information
2142 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002143 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002144 bool has_eval = false;
2145 bool has_control = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002146 if (create_info.pStages != nullptr) {
2147 for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) {
2148 active_shaders |= create_info.pStages[stage_index].stage;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002149
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002150 if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002151 has_control = true;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002152 } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002153 has_eval = true;
2154 }
2155
2156 skip |= validate_string(
2157 "vkCreateGraphicsPipelines",
2158 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002159 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", create_info.pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002160
2161 std::stringstream msg;
2162 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2163 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002164 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002165 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002166 }
2167
2168 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002169 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2170 skip |=
2171 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2172 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2173 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2174 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002175
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002176 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002177 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2178
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002179 skip |= validate_struct_pnext(
2180 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002181 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002182 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2183 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2184 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2185 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002186
2187 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002188 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002189 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2190 }
2191
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002192 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002193 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2194 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002195 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002196 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2197 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2198
2199 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002200 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002201 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002202
2203 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002204 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002205 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2206
2207 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2208 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002209 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002210 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2211
2212 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002213 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002214 }
2215
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002216 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2217 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002218
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002219 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002220 skip |=
2221 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2222 "vkCreateGraphicsPipelines: pararameter "
2223 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2224 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002225 }
2226
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002227 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002228 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002229 skip |=
2230 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2231 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2232 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2233 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2234 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002235 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2236 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002237 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002238 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2239 skip |=
2240 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2241 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002242 create_info.pVertexInputState->vertexBindingDescriptionCount,
2243 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002244 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2245
2246 skip |= validate_array(
2247 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2248 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2249 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2250 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2251
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002252 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002253 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002254 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002255 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002256 skip |= validate_ranged_enum(
2257 "vkCreateGraphicsPipelines",
2258 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2259 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002260 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002261 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2262 }
2263 }
2264
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002265 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002266 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002267 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002268 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002269 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002270 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002271 skip |= validate_ranged_enum(
2272 "vkCreateGraphicsPipelines",
2273 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2274 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002275 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002276 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002277 if (FormatIsDepthOrStencil(format)) {
2278 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2279 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2280 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2281 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002282 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2283 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002284 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2285 "alignment, replace with a color format.",
2286 i, vertex_attribute_description_index, string_VkFormat(format));
2287 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002288 }
2289 }
2290
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002291 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002292 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2293 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002294 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2295 ") is "
2296 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002297 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002298 }
2299
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002300 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002301 skip |=
2302 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2303 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002304 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2305 ") is "
2306 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002307 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002308 }
2309
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002310 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002311 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2312 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002313 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2314 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002315 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2316 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002317 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2318 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002319 "(%" PRIu32 ") is not distinct.",
2320 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002321 }
2322 vertex_bindings.insert(vertex_bind_desc.binding);
2323
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002324 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002325 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2326 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002327 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2328 "].binding (%" PRIu32
2329 ") is "
2330 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002331 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002332 }
2333
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002334 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002335 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2336 "vkCreateGraphicsPipelines: parameter "
2337 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2338 "].stride (%" PRIu32
2339 ") is greater "
2340 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2341 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002342 }
2343 }
2344
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002345 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002346 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2347 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002348 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2349 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002350 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2351 "vkCreateGraphicsPipelines: parameter "
2352 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2353 "].location (%" PRIu32 ") is not distinct.",
2354 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002355 }
2356 attribute_locations.insert(vertex_attrib_desc.location);
2357
2358 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2359 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002360 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2361 "vkCreateGraphicsPipelines: parameter "
2362 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2363 "].binding (%" PRIu32
2364 ") does not exist "
2365 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2366 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002367 }
2368
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002369 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002370 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2371 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002372 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2373 "].location (%" PRIu32
2374 ") is "
2375 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002376 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002377 }
2378
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002379 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002380 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2381 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002382 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2383 "].binding (%" PRIu32
2384 ") is "
2385 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002386 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002387 }
2388
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002389 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002390 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2391 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002392 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2393 "].offset (%" PRIu32
2394 ") is "
2395 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002396 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002397 }
2398 }
2399 }
2400
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002401 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2402 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002403 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002404 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002405 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2406 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002407 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002408 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002409 i, i);
2410 } else {
2411 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2412 skip |= validate_struct_pnext(
2413 "vkCreateGraphicsPipelines",
2414 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002415 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002416 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2417 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002418
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002419 skip |= validate_reserved_flags(
2420 "vkCreateGraphicsPipelines",
2421 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002422 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002423
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002424 if (create_info.pTessellationState->patchControlPoints == 0 ||
2425 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2426 skip |=
2427 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2428 "vkCreateGraphicsPipelines: invalid parameter "
2429 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2430 ". patchControlPoints "
2431 "should be >0 and <=%" PRIu32 ".",
2432 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002433 }
2434 }
2435 }
2436
2437 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002438 if ((create_info.pRasterizationState != nullptr) &&
2439 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2440 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002441 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2442 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2443 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2444 "].pViewportState (=NULL) is not a valid pointer.",
2445 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002446 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002447 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002448
2449 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002450 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2451 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2452 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2453 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002454 }
2455
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002456 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002457 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002458 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2459 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002460 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2461 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002462 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002463 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002464 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002465 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002466 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002467 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002468 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002469 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002470 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002471 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002472 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002473 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002474
2475 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002476 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002477 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002478 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002479
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002480 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002481 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002482 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002483 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002484 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002485 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2486 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002487 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002488 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2489 const auto depth_clip_control_struct =
2490 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002491
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002492 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002493 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002494 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2495 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2496 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2497 ") is not 1.",
2498 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002499 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002500
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002501 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002502 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2503 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2504 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2505 ") is not 1.",
2506 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002507 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002508
Dave Houlton142c4cb2018-10-17 15:04:41 -06002509 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2510 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002511 skip |= LogError(
2512 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2513 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2514 "disabled, but pCreateInfos[%" PRIu32
2515 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2516 ") is not 1.",
2517 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002518 }
2519
Jeff Bolz9af91c52018-09-01 21:53:57 -05002520 if (shading_rate_image_struct &&
2521 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2523 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2524 "disabled, but pCreateInfos[%" PRIu32
2525 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2526 ") is neither 0 nor 1.",
2527 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002528 }
2529
Petr Krausa6103552017-11-16 21:21:58 +01002530 } else { // multiViewport enabled
2531 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002532 if (!has_dynamic_viewport_with_count) {
2533 skip |= LogError(
2534 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2535 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2536 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002537 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002538 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2539 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2540 "].pViewportState->viewportCount (=%" PRIu32
2541 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2542 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002543 } else if (has_dynamic_viewport_with_count) {
2544 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2545 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2546 "].pViewportState->viewportCount (=%" PRIu32
2547 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2548 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002549 }
Petr Krausa6103552017-11-16 21:21:58 +01002550
2551 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002552 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-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002556 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002557 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002558 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2559 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002560 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002561 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2562 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2563 "].pViewportState->scissorCount (=%" PRIu32
2564 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2565 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002566 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002567 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2568 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2569 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2570 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002571 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2572 "].pViewportState->scissorCount (=%" PRIu32
2573 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2574 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002575 }
2576 }
2577
ziga-lunarg845883b2021-07-14 15:05:00 +02002578 if (!has_dynamic_scissor && viewport_state.pScissors) {
2579 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2580 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002581
2582 if (scissor.offset.x < 0) {
2583 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2584 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2585 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2586 scissor.offset.x, i, scissor_i);
2587 }
2588
2589 if (scissor.offset.y < 0) {
2590 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2591 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2592 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2593 scissor.offset.y, i, scissor_i);
2594 }
2595
ziga-lunarg845883b2021-07-14 15:05:00 +02002596 const int64_t x_sum =
2597 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2598 if (x_sum > std::numeric_limits<int32_t>::max()) {
2599 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2600 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2601 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2602 "] will overflow int32_t.",
2603 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2604 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002605
ziga-lunarg845883b2021-07-14 15:05:00 +02002606 const int64_t y_sum =
2607 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2608 if (y_sum > std::numeric_limits<int32_t>::max()) {
2609 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2610 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2611 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2612 "] will overflow int32_t.",
2613 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2614 }
2615 }
2616 }
2617
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002618 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002619 skip |=
2620 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2621 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2622 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2623 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002624 }
2625
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002626 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002627 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2628 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2629 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2630 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2631 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002632 }
2633
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002634 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2635 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2636 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2637 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2638 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2639 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2640 skip |= LogError(
2641 device, vuid,
2642 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2643 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2644 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2645 }
Petr Krausa6103552017-11-16 21:21:58 +01002646 }
2647
Dave Houlton142c4cb2018-10-17 15:04:41 -06002648 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002649 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002650 skip |=
2651 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2652 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2653 ") must be zero or identical to pCreateInfos[%" PRIu32
2654 "].pViewportState->viewportCount (=%" PRIu32 ").",
2655 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002656 }
2657
Dave Houlton142c4cb2018-10-17 15:04:41 -06002658 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002659 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002660 skip |= LogError(
2661 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002662 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2663 "] "
2664 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2665 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2666 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002667 }
2668
Petr Krausa6103552017-11-16 21:21:58 +01002669 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002670 skip |= LogError(
2671 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002672 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2673 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002674 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2675 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002676 }
2677
2678 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002679 skip |= LogError(
2680 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002681 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2682 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002683 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2684 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002685 }
2686
Jeff Bolz3e71f782018-08-29 23:15:45 -05002687 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002688 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2689 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2690 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002691 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002692 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2693 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2694 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2695 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002696 }
2697
Jeff Bolz9af91c52018-09-01 21:53:57 -05002698 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002699 shading_rate_image_struct->viewportCount > 0 &&
2700 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002701 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002702 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002703 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002704 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2705 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002706 i, i);
2707 }
2708
Chris Mayer328d8212018-12-11 14:16:18 +01002709 if (vp_swizzle_struct) {
2710 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002711 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2712 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2713 " does "
2714 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2715 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002716 }
2717 }
2718
Petr Krausb3fcdb42018-01-09 22:09:09 +01002719 // validate the VkViewports
2720 if (!has_dynamic_viewport && viewport_state.pViewports) {
2721 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2722 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002723 const char *fn_name = "vkCreateGraphicsPipelines";
2724 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2725 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2726 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002727 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002728 }
2729 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002730
sfricke-samsung45996a42021-09-16 13:45:27 -07002731 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002732 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2733 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2734 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2735 "VK_NV_clip_space_w_scaling extension is not enabled.",
2736 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002737 }
2738
sfricke-samsung45996a42021-09-16 13:45:27 -07002739 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002740 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2741 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2742 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2743 "VK_EXT_discard_rectangles extension is not enabled.",
2744 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002745 }
2746
sfricke-samsung45996a42021-09-16 13:45:27 -07002747 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002748 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2749 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2750 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2751 "VK_EXT_sample_locations extension is not enabled.",
2752 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002753 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002754
sfricke-samsung45996a42021-09-16 13:45:27 -07002755 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002756 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2757 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2758 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2759 "VK_NV_scissor_exclusive extension is not enabled.",
2760 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002761 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002762
2763 if (coarse_sample_order_struct &&
2764 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2765 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002766 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2767 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2768 "] "
2769 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2770 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2771 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002772 }
2773
2774 if (coarse_sample_order_struct) {
2775 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002776 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002777 }
2778 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002779
2780 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2781 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002782 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2783 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2784 "] "
2785 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2786 ") "
2787 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2788 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002789 }
2790 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002791 skip |= LogError(
2792 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002793 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2794 "] "
2795 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2796 i);
2797 }
2798 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002799
2800 if (depth_clip_control_struct) {
2801 const auto *depth_clip_control_features =
2802 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2803 const bool enabled_depth_clip_control =
2804 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2805 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2806 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2807 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2808 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2809 "depthClipControl feature is not enabled. ",
2810 i);
2811 }
2812 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002813 }
2814
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002815 const bool is_frag_out_graphics_lib =
2816 graphics_lib_info &&
2817 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002818 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002819 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002820 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2821 "].pRasterizationState->rasterizerDiscardEnable "
2822 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002823 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002824 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002825 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002826 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002827 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2828 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002829 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002830 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002831 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002832
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002833 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002834 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002835 skip |= validate_struct_pnext(
2836 "vkCreateGraphicsPipelines",
2837 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002838 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002839 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2840 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002841
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002842 skip |= validate_reserved_flags(
2843 "vkCreateGraphicsPipelines",
2844 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002845 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002846
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002847 skip |= validate_bool32(
2848 "vkCreateGraphicsPipelines",
2849 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002850 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002851
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002852 skip |= validate_array(
2853 "vkCreateGraphicsPipelines",
2854 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2855 ParameterName::IndexVector{i}),
2856 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002857 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
2858 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002859
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002860 skip |= validate_flags("vkCreateGraphicsPipelines",
2861 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2862 ParameterName::IndexVector{i}),
2863 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002864 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002865 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002866
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002867 skip |= validate_bool32("vkCreateGraphicsPipelines",
2868 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
2869 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002870 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002871
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002872 skip |= validate_bool32(
2873 "vkCreateGraphicsPipelines",
2874 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002875 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002876
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002877 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002878 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
2879 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2880 "].pMultisampleState->sType must be "
2881 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002882 i);
John Zulauf7acac592017-11-06 11:15:53 -07002883 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002884 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002885 if (!physical_device_features.sampleRateShading) {
2886 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2887 "vkCreateGraphicsPipelines(): parameter "
2888 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
2889 i);
2890 }
2891 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2892 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002893 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002894 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002895
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002896 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2897 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2898 "].pMultisampleState->minSampleShading.",
2899 i);
2900 }
John Zulauf7acac592017-11-06 11:15:53 -07002901 }
2902 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002903
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002904 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002905 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002906
2907 if (line_state) {
2908 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2909 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002910 if (create_info.pMultisampleState->alphaToCoverageEnable) {
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->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002915 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002916 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002917 if (create_info.pMultisampleState->alphaToOneEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002918 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002919 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2920 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002921 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002922 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002923 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002924 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002925 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002926 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2927 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002928 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002929 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002930 }
2931 }
2932 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2933 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2934 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002935 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002936 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
2937 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002938 "range [1,256].",
2939 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002940 }
2941 }
2942 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002943 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002944 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2945 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002946 skip |=
2947 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002948 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2949 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002950 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2951 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002952 }
2953 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2954 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002955 skip |=
2956 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002957 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2958 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002959 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2960 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002961 }
2962 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2963 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002964 skip |=
2965 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002966 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2967 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002968 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2969 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002970 }
2971 if (line_state->stippledLineEnable) {
2972 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2973 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002974 skip |=
2975 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002976 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2977 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002978 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2979 "stippledRectangularLines feature.",
2980 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002981 }
2982 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2983 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002984 skip |=
2985 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002986 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2987 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002988 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2989 "stippledBresenhamLines feature.",
2990 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002991 }
2992 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2993 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002994 skip |=
2995 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002996 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2997 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002998 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2999 "stippledSmoothLines feature.",
3000 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003001 }
3002 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05003003 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003004 skip |=
3005 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003006 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3007 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003008 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
3009 "stippledRectangularLines and strictLines features.",
3010 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003011 }
3012 }
3013 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003014 }
3015
Petr Krause91f7a12017-12-14 20:57:36 +01003016 bool uses_color_attachment = false;
3017 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003018 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003019 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003020 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003021 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003022 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003023 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003024 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003025 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003026 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003027 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003028 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003029 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003030 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01003031 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003032 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003033 }
3034
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003035 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003036 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003037 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003038 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003039 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003040 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003041
Mike Schuchardt00e81452021-11-29 11:11:20 -08003042 skip |=
3043 validate_flags("vkCreateGraphicsPipelines",
3044 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3045 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003046 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003047 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003048
3049 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003050 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003051 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003052 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003053
3054 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003055 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003056 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003057 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003058
3059 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003060 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003061 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003062 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003063 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003064
3065 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003066 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003067 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003068 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003069
3070 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003071 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003072 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003073 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003074
3075 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003076 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003077 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003078 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003079 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003080
3081 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003082 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003083 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003084 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003085 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003086
3087 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003088 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003089 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003090 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003091 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003092
3093 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003094 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003095 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003096 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003097 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003098
3099 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003100 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003101 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003102 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003103 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003104
3105 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003106 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003107 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003108 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003109 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003110
3111 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003112 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003113 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003114 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003115 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003116
3117 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003118 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003119 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003120 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003121 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003122
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003123 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003124 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003125 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3126 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003127 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3128 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003129 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003130
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003131 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003132 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3133 const auto *rasterization_order_attachment_access_feature =
3134 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3135 const bool rasterization_order_depth_attachment_access_feature_enabled =
3136 rasterization_order_attachment_access_feature &&
3137 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3138 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3139 skip |= LogError(
3140 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3141 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3142 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3143 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003144 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003145 }
3146
3147 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3148 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003149 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003150 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3151 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003152 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003153 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3154 }
3155 }
3156
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003157 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003158 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3159 const auto *rasterization_order_attachment_access_feature =
3160 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3161 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3162 rasterization_order_attachment_access_feature &&
3163 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3164 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3165 skip |= LogError(
3166 device,
3167 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3168 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3169 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3170 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003171 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003172 }
3173
3174 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3175 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003176 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003177 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3178 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003179 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003180 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3181 }
3182 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003183 }
3184
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003185 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003186 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3187 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003188
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003189 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3190 skip |=
3191 validate_struct_type("vkCreateGraphicsPipelines",
3192 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3193 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3194 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3195 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003196
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003197 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003198 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003199 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003200 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3201 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003202 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003203 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3204 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003205
Mike Schuchardt00e81452021-11-29 11:11:20 -08003206 skip |= validate_flags("vkCreateGraphicsPipelines",
3207 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3208 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003209 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003210 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003211
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003212 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003213 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3214 const auto *rasterization_order_attachment_access_feature =
3215 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3216 const bool rasterization_order_color_attachment_access_feature_enabled =
3217 rasterization_order_attachment_access_feature &&
3218 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3219
3220 if (!rasterization_order_color_attachment_access_feature_enabled) {
3221 skip |= LogError(
3222 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3223 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3224 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3225 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003226 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003227 }
3228
3229 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003230 skip |=
3231 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3232 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3233 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3234 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3235 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003236 }
3237 }
3238
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003239 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003240 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003241 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003242 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003243
3244 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003245 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003246 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3247 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003248 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3249 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003250
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003251 if (create_info.pColorBlendState->pAttachments != NULL) {
3252 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003253 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003254 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003255 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003256 ParameterName::IndexVector{i, attachment_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003257 create_info.pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003258
3259 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003260 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003261 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003262 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003263 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003264 create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003265 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003266
3267 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003268 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003269 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003270 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003271 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003272 create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003273 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003274
3275 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003276 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003277 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003278 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003279 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003280 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003281 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003282
3283 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003284 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003285 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003286 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003287 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003288 create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003289 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003290
3291 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003292 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003293 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003294 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003295 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003296 create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003297 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003298
3299 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003300 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003301 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003302 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003303 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003304 create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003305 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003306
3307 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003308 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003309 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003310 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003311 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003312 create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003313 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003314
3315 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3316 bool invalid = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003317 switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
ziga-lunarga283d022021-08-04 18:35:23 +02003318 case VK_BLEND_OP_ZERO_EXT:
3319 case VK_BLEND_OP_SRC_EXT:
3320 case VK_BLEND_OP_DST_EXT:
3321 case VK_BLEND_OP_SRC_OVER_EXT:
3322 case VK_BLEND_OP_DST_OVER_EXT:
3323 case VK_BLEND_OP_SRC_IN_EXT:
3324 case VK_BLEND_OP_DST_IN_EXT:
3325 case VK_BLEND_OP_SRC_OUT_EXT:
3326 case VK_BLEND_OP_DST_OUT_EXT:
3327 case VK_BLEND_OP_SRC_ATOP_EXT:
3328 case VK_BLEND_OP_DST_ATOP_EXT:
3329 case VK_BLEND_OP_XOR_EXT:
3330 case VK_BLEND_OP_INVERT_EXT:
3331 case VK_BLEND_OP_INVERT_RGB_EXT:
3332 case VK_BLEND_OP_LINEARDODGE_EXT:
3333 case VK_BLEND_OP_LINEARBURN_EXT:
3334 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3335 case VK_BLEND_OP_LINEARLIGHT_EXT:
3336 case VK_BLEND_OP_PINLIGHT_EXT:
3337 case VK_BLEND_OP_HARDMIX_EXT:
3338 case VK_BLEND_OP_PLUS_EXT:
3339 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3340 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3341 case VK_BLEND_OP_PLUS_DARKER_EXT:
3342 case VK_BLEND_OP_MINUS_EXT:
3343 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3344 case VK_BLEND_OP_CONTRAST_EXT:
3345 case VK_BLEND_OP_INVERT_OVG_EXT:
3346 case VK_BLEND_OP_RED_EXT:
3347 case VK_BLEND_OP_GREEN_EXT:
3348 case VK_BLEND_OP_BLUE_EXT:
3349 invalid = true;
3350 break;
3351 default:
3352 break;
3353 }
3354 if (invalid) {
3355 skip |= LogError(
3356 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3357 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3358 "].pColorBlendState->pAttachments[%" PRIu32
3359 "].colorBlendOp (%s) is not valid when "
3360 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3361 "VK_FALSE",
3362 i, attachment_index,
3363 string_VkBlendOp(
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003364 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp));
ziga-lunarga283d022021-08-04 18:35:23 +02003365 }
3366 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003367 }
3368 }
3369
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003370 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003371 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003372 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3373 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003374 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3375 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003376 }
3377
3378 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003379 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003380 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003381 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003382 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003383 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003384 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003385 }
3386 }
3387 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003388
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003389 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003390 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003391 if (create_info.basePipelineIndex != -1) {
3392 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003393 skip |=
3394 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003395 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3396 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003397 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003398 "and pCreateInfos->basePipelineIndex is not -1.",
3399 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003400 }
3401 }
3402
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003403 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3404 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003405 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003406 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3407 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003408 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003409 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3410 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003411 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003412 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003413 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003414 skip |=
3415 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003416 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3417 ") must be a valid"
3418 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003419 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003420 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003421 }
3422 }
3423
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003424 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003425 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003426 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003427 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003428 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3429 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3430 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3431 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003432 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003433 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003434 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003435 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003436 "pCreateInfos[%" PRIu32
3437 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003438 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3439 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003440 }
3441 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003442 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3443 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003444 (physical_device_features.fillModeNonSolid == false)) {
3445 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003446 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3447 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003448 "pCreateInfos[%" PRIu32
3449 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003450 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3451 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003452 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003453 }
Petr Kraus299ba622017-11-24 03:09:03 +01003454
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003455 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003456 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003457 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3458 "The line width state is static (pCreateInfos[%" PRIu32
3459 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3460 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3461 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003462 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003463 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003464 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003465
3466 // Validate no flags not allowed are used
3467 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003468 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003469 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3470 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003471 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3472 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003473 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003474 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3475 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003476 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
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_LIBRARY_BIT_KHR.",
3480 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003481 }
3482 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3483 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
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_ANY_HIT_SHADERS_BIT_KHR.",
3487 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003488 }
3489 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3490 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
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_CLOSEST_HIT_SHADERS_BIT_KHR.",
3494 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003495 }
3496 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3497 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
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_NO_NULL_MISS_SHADERS_BIT_KHR.",
3501 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003502 }
3503 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3504 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
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_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3508 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003509 }
3510 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3511 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
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_SKIP_TRIANGLES_BIT_KHR.",
3515 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003516 }
3517 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3518 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003519 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3520 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003521 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3522 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003523 }
3524 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3525 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003526 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3527 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003528 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3529 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003530 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003531 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3532 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3533 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3534 "]->flags (0x%x) must not include "
3535 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3536 i, flags);
3537 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003538 }
3539 }
3540
3541 return skip;
3542}
3543
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003544bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3545 uint32_t createInfoCount,
3546 const VkComputePipelineCreateInfo *pCreateInfos,
3547 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003548 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003549 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003550 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003551 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003552 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003553 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003554 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003555 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003556 skip |=
Tony-LunarGce3244a2021-11-19 12:33:40 -07003557 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02669",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003558 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3559 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3560 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003561 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003562
3563 // Make sure compute stage is selected
3564 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003565 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003566 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3567 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003568 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003569 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003570
sfricke-samsungeb549012021-04-16 01:25:51 -07003571 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3572 // Validate no flags not allowed are used
3573 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003574 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3575 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3576 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3577 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003578 }
3579 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3580 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
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_ANY_HIT_SHADERS_BIT_KHR.",
3584 i, flags);
3585 }
3586 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3587 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
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_CLOSEST_HIT_SHADERS_BIT_KHR.",
3591 i, flags);
3592 }
3593 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3594 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
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_NO_NULL_MISS_SHADERS_BIT_KHR.",
3598 i, flags);
3599 }
3600 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3601 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
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_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3605 i, flags);
3606 }
3607 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3608 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
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_SKIP_TRIANGLES_BIT_KHR.",
3612 i, flags);
3613 }
3614 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3615 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003616 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3617 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003618 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3619 i, flags);
3620 }
3621 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3622 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
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_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3626 i, flags);
3627 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003628 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3629 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003630 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3631 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003632 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3633 i, flags);
3634 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003635 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3636 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003637 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3638 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003639 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3640 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003641 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003642 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3643 if (pCreateInfos[i].basePipelineIndex != -1) {
3644 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3645 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3646 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3647 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3648 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3649 i);
3650 }
3651 }
3652
3653 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3654 if (pCreateInfos[i].basePipelineIndex != -1) {
3655 skip |= LogError(
3656 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3657 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3658 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3659 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3660 i);
3661 }
3662 } else {
3663 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3664 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3665 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3666 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3667 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3668 }
3669 }
3670 }
ziga-lunargc6341372021-07-28 12:57:42 +02003671
3672 std::stringstream msg;
3673 msg << "pCreateInfos[%" << i << "].stage";
3674 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003675 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003676 return skip;
3677}
3678
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003679bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003680 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003681 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003682
3683 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003684 const auto &features = physical_device_features;
3685 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003686
John Zulauf71968502017-10-26 13:51:15 -06003687 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3688 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003689 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3690 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3691 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3692 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003693 }
3694
3695 // Anistropy cannot be enabled in sampler unless enabled as a feature
3696 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003697 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3698 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3699 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003700 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003701 }
John Zulauf71968502017-10-26 13:51:15 -06003702
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003703 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3704 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003705 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3706 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3707 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3708 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003709 }
3710 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003711 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3712 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3713 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3714 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003715 }
3716 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003717 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3718 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3719 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3720 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003721 }
3722 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3723 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3724 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3725 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003726 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3727 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3728 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3729 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3730 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3731 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003732 }
3733 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003734 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3735 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3736 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003737 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003738 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003739 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3740 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3741 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003742 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003743 }
3744
3745 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3746 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003747 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3748 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003749 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003750 if (sampler_reduction != nullptr) {
3751 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3752 skip |= LogError(
3753 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3754 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3755 }
3756 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003757 }
3758
3759 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3760 // valid VkBorderColor value
3761 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3762 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3763 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003764 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3765 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003766 }
3767
John Zulauf275805c2017-10-26 15:34:49 -06003768 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003769 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003770 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3771 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003772 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3773 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3774 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003775 }
3776 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003777
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003778 // Check for valid Lod range
3779 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003780 skip |=
3781 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3782 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003783 }
3784
3785 // Check mipLodBias to device limit
3786 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003787 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3788 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3789 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003790 }
3791
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003792 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003793 if (sampler_conversion != nullptr) {
3794 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3795 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3796 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3797 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003798 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003799 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003800 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3801 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3802 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3803 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3804 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3805 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3806 }
3807 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003808
3809 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3810 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3811 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3812 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3813 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3814 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3815 }
3816 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3817 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3818 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3819 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3820 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3821 }
3822 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3823 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3824 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3825 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3826 pCreateInfo->minLod, pCreateInfo->maxLod);
3827 }
3828 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3829 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3830 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3831 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3832 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3833 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3834 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3835 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3836 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3837 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3838 }
3839 if (pCreateInfo->anisotropyEnable) {
3840 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3841 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3842 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3843 }
3844 if (pCreateInfo->compareEnable) {
3845 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3846 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3847 "pCreateInfo->compareEnable must be VK_FALSE");
3848 }
3849 if (pCreateInfo->unnormalizedCoordinates) {
3850 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3851 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3852 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3853 }
3854 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003855
Piers Daniell833b9492021-11-20 11:47:10 -07003856 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3857 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3858 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
3859 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3860 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3861 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3862 }
3863 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
3864 if (!custom_create_info) {
3865 skip |= LogError(
3866 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3867 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3868 "struct in pNext chain.\n",
3869 string_VkBorderColor(pCreateInfo->borderColor));
3870 } else {
3871 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3872 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
3873 !FormatIsSampledInt(custom_create_info->format)) ||
3874 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3875 !FormatIsSampledFloat(custom_create_info->format)))) {
3876 skip |=
3877 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06003878 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3879 "whose type does not match\n",
3880 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07003881 ;
3882 }
3883 }
3884 }
3885
3886 const auto *border_color_component_mapping =
3887 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
3888 if (border_color_component_mapping) {
3889 const auto *border_color_swizzle_features =
3890 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
3891 bool border_color_swizzle_features_enabled =
3892 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
3893 if (!border_color_swizzle_features_enabled) {
3894 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
3895 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
3896 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06003897 }
3898 }
3899 }
3900
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003901 return skip;
3902}
3903
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003904bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
3905 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
3906 const char *func_name) const {
3907 bool skip = false;
3908
3909 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
3910 uint32_t mutable_type_count = 0;
3911 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
3912 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
3913 }
3914 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3915 if (mutable_type_count == 0) {
3916 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
3917 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3918 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
3919 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3920 "].descriptorTypeCount is 0.",
3921 func_name, i, i);
3922 }
3923 } else {
3924 if (mutable_type_count > 0) {
3925 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
3926 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3927 "].descriptorType is %s, but "
3928 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3929 "].descriptorTypeCount is not 0.",
3930 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
3931 }
3932 }
3933 }
3934
3935 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
3936 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
3937 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
3938 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
3939 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
3940 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3941 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
3942 func_name, j, k);
3943 break;
3944 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
3945 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
3946 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3947 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
3948 func_name, j, k);
3949 break;
3950 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
3951 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
3952 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3953 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
3954 func_name, j, k);
3955 break;
3956 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
3957 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
3958 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3959 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
3960 func_name, j, k);
3961 break;
3962 default:
3963 break;
3964 }
3965 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
3966 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
3967 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
3968 skip |=
3969 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
3970 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3971 "].pDescriptorTypes[%" PRIu32
3972 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3973 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
3974 func_name, j, k, j, l,
3975 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
3976 }
3977 }
3978 }
3979 }
3980
3981 return skip;
3982}
3983
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003984bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3985 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3986 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003987 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003988 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003989
ziga-lunargfc6896f2021-10-15 18:46:12 +02003990 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
3991 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
3992 bool mutable_descriptor_type_features_enabled =
3993 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
3994
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003995 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3996 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3997 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3998 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003999 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4000 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4001 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4002 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4003 ++descriptor_index) {
4004 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004005 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004006 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004007 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4008 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004009 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004010 }
4011 }
4012 }
4013
4014 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4015 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4016 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004017 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004018 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4019 "].descriptorCount is not 0, "
4020 "pCreateInfo->pBindings[%" PRIu32
4021 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004022 "values.",
4023 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004024 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004025
4026 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4027 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4028 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004029 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4030 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4031 "].descriptorCount is not 0 and "
4032 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4033 "].stageFlags "
4034 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4035 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004036 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004037
4038 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4039 if (!mutable_descriptor_type) {
4040 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4041 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4042 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4043 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4044 i);
4045 }
4046 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4047 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4048 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4049 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4050 "pImmutableSamplers is not NULL.",
4051 i);
4052 }
4053 if (!mutable_descriptor_type_features_enabled) {
4054 skip |= LogError(
4055 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4056 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4057 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4058 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4059 i);
4060 }
4061 }
4062
4063 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4064 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4065 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4066 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4067 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4068 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4069 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004070 }
4071 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004072
4073 if (mutable_descriptor_type) {
4074 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
4075 "vkDescriptorSetLayoutCreateInfo");
4076 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004077 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004078 if (pCreateInfo) {
4079 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4080 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4081 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4082 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4083 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4084 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4085 }
4086 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4087 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4088 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4089 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4090 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4091 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4092 }
4093 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4094 !mutable_descriptor_type_features_enabled) {
4095 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4096 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4097 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4098 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4099 }
4100 }
4101
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004102 return skip;
4103}
4104
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004105bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4106 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004107 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004108 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4109 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4110 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004111 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4112 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004113}
4114
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004115bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4116 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004117 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004118 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004119
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004120 if (pDescriptorWrites != NULL) {
4121 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4122 // descriptorCount must be greater than 0
4123 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004124 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4125 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4126 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004127 }
4128
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004129 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004130 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004131 // dstSet must be a valid VkDescriptorSet handle
4132 skip |= validate_required_handle(vkCallingFunction,
4133 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4134 pDescriptorWrites[i].dstSet);
4135 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004136
4137 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4138 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4139 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4140 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4141 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004142 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004143 if (!isPushDescriptor) {
4144 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4145 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4146 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4147 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4148 // ObjectLifetimes::ValidateDescriptorWrite.
4149 skip |= LogError(
4150 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4151 "%s(): if pDescriptorWrites[%" PRIu32
4152 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4153 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4154 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4155 vkCallingFunction, i, i);
4156 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4157 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4158 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4159 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4160 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4161 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4162 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4163 "%s(): if pDescriptorWrites[%" PRIu32
4164 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4165 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4166 "].pImageInfo must not be NULL.",
4167 vkCallingFunction, i, i);
4168 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004169 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4170 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004171 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4172 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004173 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4174 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004175 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004176 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4177 ParameterName::IndexVector{i, descriptor_index}),
4178 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004179 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004180 }
4181 }
4182 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4183 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4184 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4185 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4186 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4187 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4188 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004189 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004190 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004191 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004192 "%s(): if pDescriptorWrites[%" PRIu32
4193 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004194 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4195 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004196 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004197 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004198 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004199 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004200 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004201 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004202 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4203 ++descriptor_index) {
4204 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4205 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4206 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004207 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004208 "%s(): if pDescriptorWrites[%" PRIu32
4209 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004210 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004211 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4212 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004213 }
4214 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004215 }
4216 }
4217 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4218 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004219 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004220 }
4221
4222 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4223 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004224 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
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, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004228 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004229 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
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 minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004232 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004233 }
4234 }
4235 }
4236 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4237 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004238 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004239 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4240 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004241 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004242 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004243 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004244 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004245 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004246 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004247 }
4248 }
4249 }
4250 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004251 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4252 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004253 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004254 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004255 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4256 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4257 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4258 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004259 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004260 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4261 pDescriptorWrites[i].descriptorCount);
4262 }
4263 // further checks only if we have right structtype
4264 if (pnext_struct) {
4265 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4266 skip |= LogError(
4267 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004268 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4269 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004270 ".",
4271 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004272 }
sourav parmarbcee7512020-12-28 14:34:49 -08004273 if (pnext_struct->accelerationStructureCount == 0) {
4274 skip |= LogError(device,
4275 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004276 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004277 }
4278 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004279 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004280 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4281 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4282 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4283 skip |= LogError(device,
4284 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4285 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004286 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004287 }
4288 }
4289 }
sourav parmarbcee7512020-12-28 14:34:49 -08004290 }
4291 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004292 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004293 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4294 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4295 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4296 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004297 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004298 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4299 pDescriptorWrites[i].descriptorCount);
4300 }
4301 // further checks only if we have right structtype
4302 if (pnext_struct) {
4303 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4304 skip |= LogError(
4305 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004306 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4307 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004308 ".",
4309 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004310 }
sourav parmarbcee7512020-12-28 14:34:49 -08004311 if (pnext_struct->accelerationStructureCount == 0) {
4312 skip |= LogError(device,
4313 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004314 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004315 }
4316 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004317 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004318 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4319 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4320 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4321 skip |= LogError(device,
4322 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4323 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004324 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004325 }
4326 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004327 }
4328 }
4329 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004330 }
4331 }
4332 return skip;
4333}
4334
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004335bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4336 const VkWriteDescriptorSet *pDescriptorWrites,
4337 uint32_t descriptorCopyCount,
4338 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004339 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004340}
4341
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004342bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004343 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004344 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004345 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4346}
4347
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004348bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4349 const VkAllocationCallbacks *pAllocator,
4350 VkRenderPass *pRenderPass) const {
4351 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4352}
4353
Mike Schuchardt2df08912020-12-15 16:28:09 -08004354bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004355 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004356 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004357 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4358}
4359
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004360bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4361 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004362 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004363 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004364
4365 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4366 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4367 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004368 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4369 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004370 return skip;
4371}
4372
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004373bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004374 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004375 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004376
4377 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4378 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004379 bool cb_is_secondary;
4380 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004381 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004382 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4383 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004384
Tony-LunarG3c287f62020-12-17 12:39:49 -07004385 if (cb_is_secondary) {
4386 // Implicit VUs
4387 // validate only sType here; pointer has to be validated in core_validation
4388 const bool k_not_required = false;
4389 const char *k_no_vuid = nullptr;
4390 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4391 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004392 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4393 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004394
Tony-LunarG3c287f62020-12-17 12:39:49 -07004395 if (info) {
4396 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004397 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004398 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4399 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004400 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004401 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004402 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4403 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4404 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4405 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004406
Tony-LunarG3c287f62020-12-17 12:39:49 -07004407 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004408
Tony-LunarG3c287f62020-12-17 12:39:49 -07004409 // Explicit VUs
4410 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004411 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004412 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4413 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4414 cmd_name);
4415 }
4416
4417 if (physical_device_features.inheritedQueries) {
4418 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004419 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4420 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4421 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004422 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004423 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004424 }
4425
4426 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004427 skip |=
4428 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4429 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4430 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4431 } else { // !pipelineStatisticsQuery
4432 skip |=
4433 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4434 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004435 }
4436
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004437 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004438 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004439 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004440 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4441 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4442 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004443 commandBuffer,
4444 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004445 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4446 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4447 }
Petr Kraus139757b2019-08-15 17:19:33 +02004448 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004449
4450 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4451 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4452 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4453 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4454 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4455 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4456 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4457 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4458 }
Petr Kraus139757b2019-08-15 17:19:33 +02004459 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004460 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004461 return skip;
4462}
4463
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004464bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004465 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004466 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004467
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004468 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004469 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004470 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4471 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4472 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004473 }
4474 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004475 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4476 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4477 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004478 }
4479 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004480 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004481 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004482 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4483 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4484 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4485 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004486 }
4487 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004488
4489 if (pViewports) {
4490 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4491 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004492 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004493 skip |= manual_PreCallValidateViewport(
4494 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004495 }
4496 }
4497
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004498 return skip;
4499}
4500
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004501bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004502 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004503 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004504
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004505 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004506 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004507 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4508 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4509 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004510 }
4511 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004512 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4513 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4514 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004515 }
4516 } else { // multiViewport enabled
4517 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004518 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004519 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4520 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4521 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4522 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004523 }
4524 }
4525
Petr Kraus6260f0a2018-02-27 21:15:55 +01004526 if (pScissors) {
4527 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4528 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004529
Petr Kraus6260f0a2018-02-27 21:15:55 +01004530 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004531 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4532 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4533 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004534 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004535
Petr Kraus6260f0a2018-02-27 21:15:55 +01004536 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004537 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4538 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4539 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004540 }
4541
4542 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4543 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004544 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4545 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4546 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4547 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004548 }
4549
4550 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4551 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004552 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4553 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4554 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4555 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004556 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004557 }
4558 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004559
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004560 return skip;
4561}
4562
Jeff Bolz5c801d12019-10-09 10:38:45 -05004563bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004564 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004565
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004566 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004567 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4568 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004569 }
4570
4571 return skip;
4572}
4573
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004574bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004575 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004576 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004577
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004578 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004579 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004580 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4581 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004582 }
4583 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004584 skip |=
4585 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4586 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4587 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004588 }
4589 return skip;
4590}
4591
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004592bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004593 VkDeviceSize offset, uint32_t drawCount,
4594 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004595 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004596 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004597 skip |=
4598 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4599 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4600 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004601 }
4602 if (drawCount > device_limits.maxDrawIndirectCount) {
4603 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004604 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4605 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004606 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004607 }
4608 return skip;
4609}
4610
sfricke-samsungf692b972020-05-02 08:00:45 -07004611bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4612 VkDeviceSize countBufferOffset, bool khr) const {
4613 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004614 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004615 if (offset & 3) {
4616 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004617 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004618 }
4619
4620 if (countBufferOffset & 3) {
4621 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004622 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004623 countBufferOffset);
4624 }
4625 return skip;
4626}
4627
4628bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4629 VkDeviceSize offset, VkBuffer countBuffer,
4630 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4631 uint32_t stride) const {
4632 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4633}
4634
4635bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4636 VkDeviceSize offset, VkBuffer countBuffer,
4637 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4638 uint32_t stride) const {
4639 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4640}
4641
4642bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4643 VkDeviceSize countBufferOffset, bool khr) const {
4644 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004645 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004646 if (offset & 3) {
4647 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004648 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004649 }
4650
4651 if (countBufferOffset & 3) {
4652 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004653 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004654 countBufferOffset);
4655 }
4656 return skip;
4657}
4658
4659bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4660 VkDeviceSize offset, VkBuffer countBuffer,
4661 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4662 uint32_t stride) const {
4663 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4664}
4665
4666bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4667 VkDeviceSize offset, VkBuffer countBuffer,
4668 VkDeviceSize countBufferOffset,
4669 uint32_t maxDrawCount, uint32_t stride) const {
4670 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4671}
4672
Tony-LunarG4490de42021-06-21 15:49:19 -06004673bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4674 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4675 uint32_t firstInstance, uint32_t stride) const {
4676 bool skip = false;
4677 if (stride & 3) {
4678 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4679 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4680 }
4681 if (drawCount && nullptr == pVertexInfo) {
4682 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4683 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4684 "one or more valid instances of VkMultiDrawInfoEXT structures");
4685 }
4686 return skip;
4687}
4688
4689bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4690 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4691 uint32_t instanceCount, uint32_t firstInstance,
4692 uint32_t stride, const int32_t *pVertexOffset) const {
4693 bool skip = false;
4694 if (stride & 3) {
4695 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4696 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4697 }
4698 if (drawCount && nullptr == pIndexInfo) {
4699 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4700 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4701 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4702 }
4703 return skip;
4704}
4705
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004706bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4707 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004708 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004709 bool skip = false;
4710 for (uint32_t rect = 0; rect < rectCount; rect++) {
4711 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004712 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004713 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004714 }
sfricke-samsung10867682020-04-25 02:20:39 -07004715 if (pRects[rect].rect.extent.width == 0) {
4716 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004717 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004718 }
4719 if (pRects[rect].rect.extent.height == 0) {
4720 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004721 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004722 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004723 }
4724 return skip;
4725}
4726
Andrew Fobel3abeb992020-01-20 16:33:22 -05004727bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4728 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4729 VkImageFormatProperties2 *pImageFormatProperties,
4730 const char *apiName) const {
4731 bool skip = false;
4732
4733 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004734 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004735 if (image_stencil_struct != nullptr) {
4736 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4737 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4738 // No flags other than the legal attachment bits may be set
4739 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4740 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004741 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4742 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4743 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4744 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4745 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004746 }
4747 }
4748 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004749 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4750 if (image_drm_format) {
4751 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4752 skip |= LogError(
4753 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4754 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4755 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4756 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4757 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004758 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4759 skip |= LogError(
4760 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4761 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4762 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4763 apiName, image_drm_format->queueFamilyIndexCount);
4764 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004765 } else {
4766 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4767 skip |= LogError(
4768 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4769 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4770 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4771 apiName);
4772 }
4773 }
4774 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4775 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4776 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4777 if (!format_list || format_list->viewFormatCount == 0) {
4778 skip |= LogError(
4779 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4780 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4781 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4782 apiName);
4783 }
4784 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004785 }
4786
4787 return skip;
4788}
4789
4790bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4791 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4792 VkImageFormatProperties2 *pImageFormatProperties) const {
4793 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4794 "vkGetPhysicalDeviceImageFormatProperties2");
4795}
4796
4797bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4798 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4799 VkImageFormatProperties2 *pImageFormatProperties) const {
4800 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4801 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4802}
4803
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004804bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4805 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4806 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4807 bool skip = false;
4808
4809 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4810 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4811 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4812 }
4813
4814 return skip;
4815}
4816
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004817bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4818 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4819 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4820 bool skip = false;
4821
4822 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4823 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4824 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4825 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4826 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4827 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4828 }
4829
ziga-lunarg42f884b2021-08-25 16:13:20 +02004830 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004831}
4832
sfricke-samsung3999ef62020-02-09 17:05:59 -08004833bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4834 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4835 bool skip = false;
4836
4837 if (pRegions != nullptr) {
4838 for (uint32_t i = 0; i < regionCount; i++) {
4839 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004840 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004841 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004842 }
4843 }
4844 }
4845 return skip;
4846}
4847
Jeff Leger178b1e52020-10-05 12:22:23 -04004848bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4849 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4850 bool skip = false;
4851
4852 if (pCopyBufferInfo->pRegions != nullptr) {
4853 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4854 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06004855 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004856 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004857 }
4858 }
4859 }
4860 return skip;
4861}
4862
Tony-LunarGef035472021-11-02 10:23:33 -06004863bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
4864 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
4865 bool skip = false;
4866
4867 if (pCopyBufferInfo->pRegions != nullptr) {
4868 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4869 if (pCopyBufferInfo->pRegions[i].size == 0) {
4870 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
4871 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
4872 }
4873 }
4874 }
4875 return skip;
4876}
4877
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004878bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004879 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4880 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004881 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004882
4883 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004884 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4885 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4886 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004887 }
4888
4889 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004890 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4891 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4892 "), must be greater than zero and less than or equal to 65536.",
4893 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004894 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004895 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4896 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4897 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004898 }
4899 return skip;
4900}
4901
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004902bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004903 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004904 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004905
4906 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004907 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4908 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4909 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004910 }
4911
4912 if (size != VK_WHOLE_SIZE) {
4913 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004914 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004915 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4916 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004917 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004918 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4919 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004920 }
4921 }
4922 return skip;
4923}
4924
sfricke-samsunga1d00272021-03-10 21:37:41 -08004925bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004926 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004927
4928 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004929 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4930 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4931 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4932 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004933 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004934 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4935 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4936 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004937 }
4938
4939 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4940 // queueFamilyIndexCount uint32_t values
4941 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004942 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004943 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004944 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004945 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4946 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004947 }
4948 }
4949
Dave Houlton413a6782018-05-22 13:01:54 -06004950 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004951 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004952
sfricke-samsunga1d00272021-03-10 21:37:41 -08004953 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4954 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4955 if (format_list_info) {
4956 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4957 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4958 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4959 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004960 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
4961 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004962 func_name, viewFormatCount);
4963 }
4964
4965 // Using the first format, compare the rest of the formats against it that they are compatible
4966 for (uint32_t i = 1; i < viewFormatCount; i++) {
4967 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4968 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4969 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4970 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004971 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
4972 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004973 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4974 string_VkFormat(format_list_info->pViewFormats[i]));
4975 }
4976 }
4977 }
4978
4979 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4980 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4981 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4982 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4983 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4984 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4985 func_name);
4986 } else {
4987 if (format_list_info == nullptr) {
4988 skip |= LogError(
4989 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4990 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4991 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4992 func_name);
4993 } else if (format_list_info->viewFormatCount == 0) {
4994 skip |= LogError(
4995 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4996 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4997 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4998 func_name);
4999 } else {
5000 bool found_base_format = false;
5001 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5002 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5003 found_base_format = true;
5004 break;
5005 }
5006 }
5007 if (!found_base_format) {
5008 skip |=
5009 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5010 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5011 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5012 "pCreateInfo->imageFormat.",
5013 func_name);
5014 }
5015 }
5016 }
5017 }
5018 }
5019 return skip;
5020}
5021
5022bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5023 const VkAllocationCallbacks *pAllocator,
5024 VkSwapchainKHR *pSwapchain) const {
5025 bool skip = false;
5026 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5027 return skip;
5028}
5029
5030bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5031 const VkSwapchainCreateInfoKHR *pCreateInfos,
5032 const VkAllocationCallbacks *pAllocator,
5033 VkSwapchainKHR *pSwapchains) const {
5034 bool skip = false;
5035 if (pCreateInfos) {
5036 for (uint32_t i = 0; i < swapchainCount; i++) {
5037 std::stringstream func_name;
5038 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5039 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5040 }
5041 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005042 return skip;
5043}
5044
Jeff Bolz5c801d12019-10-09 10:38:45 -05005045bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005046 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005047
5048 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005049 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005050 if (present_regions) {
5051 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005052 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005053 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5054 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005055 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005056 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5057 "extension swapchainCount is %i. These values must be equal.",
5058 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005059 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005060 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005061 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5062 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005063 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5064 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5065 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005066 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005067 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005068 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005069 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005070 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005071 }
5072 }
5073
5074 return skip;
5075}
5076
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005077bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5078 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5079 const VkAllocationCallbacks *pAllocator,
5080 VkDisplayModeKHR *pMode) const {
5081 bool skip = false;
5082
5083 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5084 if (display_mode_parameters.visibleRegion.width == 0) {
5085 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5086 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5087 }
5088 if (display_mode_parameters.visibleRegion.height == 0) {
5089 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5090 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5091 }
5092 if (display_mode_parameters.refreshRate == 0) {
5093 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5094 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5095 }
5096
5097 return skip;
5098}
5099
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005100#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005101bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5102 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5103 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005104 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005105 bool skip = false;
5106
5107 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005108 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5109 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005110 }
5111
5112 return skip;
5113}
5114#endif // VK_USE_PLATFORM_WIN32_KHR
5115
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005116static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5117 bool partial_overlap = false;
5118
5119 static const std::vector<VkDescriptorType> all_descriptor_types = {
5120 VK_DESCRIPTOR_TYPE_SAMPLER,
5121 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5122 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5123 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5124 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5125 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5126 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5127 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5128 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5129 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5130 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5131 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5132 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5133 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5134 };
5135
5136 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5137 if (mutable_descriptor_type) {
5138 std::vector<VkDescriptorType> first_types, second_types;
5139 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5140 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5141 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5142 }
5143 } else {
5144 first_types = all_descriptor_types;
5145 }
5146 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5147 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5148 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5149 }
5150 } else {
5151 second_types = all_descriptor_types;
5152 }
5153
5154 bool complete_overlap = first_types.size() == second_types.size();
5155 bool disjoint = true;
5156 for (const auto first_type : first_types) {
5157 bool found = false;
5158 for (const auto second_type : second_types) {
5159 if (first_type == second_type) {
5160 found = true;
5161 break;
5162 }
5163 }
5164 if (found) {
5165 disjoint = false;
5166 } else {
5167 complete_overlap = false;
5168 }
5169 if (!disjoint && !complete_overlap) {
5170 partial_overlap = true;
5171 break;
5172 }
5173 }
5174 }
5175
5176 return partial_overlap;
5177}
5178
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005179bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005180 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005181 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005182 bool skip = false;
5183
5184 if (pCreateInfo) {
5185 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005186 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5187 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005188 }
5189
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005190 const auto *mutable_descriptor_type_features =
5191 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5192 bool mutable_descriptor_type_enabled =
5193 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5194
Petr Krausc8655be2017-09-27 18:56:51 +02005195 if (pCreateInfo->pPoolSizes) {
5196 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5197 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005198 skip |= LogError(
5199 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005200 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005201 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005202 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5203 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005204 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5205 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5206 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5207 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5208 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005209 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005210 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5211 skip |=
5212 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5213 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5214 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5215 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5216 i);
5217 }
5218 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5219 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5220 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5221 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5222 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5223 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5224 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5225 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5226 " and have sets which partially overlap.",
5227 i, j);
5228 }
5229 }
5230 }
5231 }
Petr Krausc8655be2017-09-27 18:56:51 +02005232 }
5233 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005234
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005235 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5236 skip |=
5237 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5238 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5239 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5240 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005241 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5242 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5243 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5244 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5245 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5246 }
Petr Krausc8655be2017-09-27 18:56:51 +02005247 }
5248
5249 return skip;
5250}
5251
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005252bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005253 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005254 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005255
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005256 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005257 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005258 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5259 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5260 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005261 }
5262
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005263 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005264 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005265 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5266 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5267 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005268 }
5269
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005270 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005271 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005272 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5273 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5274 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005275 }
5276
5277 return skip;
5278}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005279
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005280bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005281 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005282 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005283
5284 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005285 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5286 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005287 }
5288 return skip;
5289}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005290
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005291bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5292 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005293 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005294 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005295
5296 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005297 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005298 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005299 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5300 "vkCmdDispatch(): baseGroupX (%" PRIu32
5301 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5302 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005303 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005304 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5305 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5306 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5307 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005308 }
5309
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005310 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005311 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005312 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5313 "vkCmdDispatch(): baseGroupY (%" PRIu32
5314 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5315 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005316 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005317 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5318 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5319 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5320 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005321 }
5322
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005323 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005324 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005325 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5326 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5327 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5328 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005329 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005330 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5331 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5332 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5333 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005334 }
5335
5336 return skip;
5337}
5338
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005339bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5340 VkPipelineBindPoint pipelineBindPoint,
5341 VkPipelineLayout layout, uint32_t set,
5342 uint32_t descriptorWriteCount,
5343 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005344 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005345}
5346
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005347bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5348 uint32_t firstExclusiveScissor,
5349 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005350 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005351 bool skip = false;
5352
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005353 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005354 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005355 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005356 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5357 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5358 ") is not 0.",
5359 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005360 }
5361 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005362 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005363 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5364 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5365 ") is not 1.",
5366 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005367 }
5368 } else { // multiViewport enabled
5369 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005370 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005371 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5372 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5373 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5374 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005375 }
5376 }
5377
Jeff Bolz3e71f782018-08-29 23:15:45 -05005378 if (pExclusiveScissors) {
5379 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5380 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5381
5382 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005383 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5384 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5385 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005386 }
5387
5388 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005389 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5390 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5391 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005392 }
5393
5394 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5395 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005396 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5397 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5398 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5399 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005400 }
5401
5402 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5403 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005404 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5405 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5406 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5407 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005408 }
5409 }
5410 }
5411
5412 return skip;
5413}
5414
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005415bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5416 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005417 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005418 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005419 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5420 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5421 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5422 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5423 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5424 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005425 }
5426
5427 return skip;
5428}
5429
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005430bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5431 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005432 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005433 bool skip = false;
5434
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005435 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005436 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005437 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005438 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5439 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5440 ") is not 0.",
5441 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005442 }
5443 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005444 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005445 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5446 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5447 ") is not 1.",
5448 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005449 }
5450 }
5451
Jeff Bolz9af91c52018-09-01 21:53:57 -05005452 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005453 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005454 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5455 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5456 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5457 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005458 }
5459
5460 return skip;
5461}
5462
Jeff Bolz5c801d12019-10-09 10:38:45 -05005463bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5464 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5465 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005466 bool skip = false;
5467
Dave Houlton142c4cb2018-10-17 15:04:41 -06005468 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005469 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5470 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5471 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005472 }
5473
5474 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005475 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005476 }
5477
5478 return skip;
5479}
5480
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005481bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005482 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005483 bool skip = false;
5484
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005485 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005486 skip |= LogError(
5487 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005488 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5489 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005490 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005491 }
5492
5493 return skip;
5494}
5495
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005496bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5497 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005498 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005499 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005500 static const int condition_multiples = 0b0011;
5501 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005502 skip |= LogError(
5503 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005504 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005505 }
Lockee1c22882019-06-10 16:02:54 -06005506 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005507 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5508 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5509 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5510 stride);
Lockee1c22882019-06-10 16:02:54 -06005511 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005512 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005513 skip |= LogError(
5514 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005515 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5516 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005517 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005518 if (drawCount > device_limits.maxDrawIndirectCount) {
5519 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005520 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5521 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005522 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005523 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005524 return skip;
5525}
5526
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005527bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5528 VkDeviceSize offset, VkBuffer countBuffer,
5529 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005530 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005531 bool skip = false;
5532
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005533 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005534 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5535 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5536 "), is not a multiple of 4.",
5537 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005538 }
5539
5540 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005541 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5542 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5543 "), is not a multiple of 4.",
5544 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005545 }
5546
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005547 return skip;
5548}
5549
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005550bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005551 const VkAllocationCallbacks *pAllocator,
5552 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005553 bool skip = false;
5554
5555 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5556 if (pCreateInfo != nullptr) {
5557 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5558 // VkQueryPipelineStatisticFlagBits values
5559 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5560 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005561 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5562 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5563 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5564 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005565 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005566 if (pCreateInfo->queryCount == 0) {
5567 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5568 "vkCreateQueryPool(): queryCount must be greater than zero.");
5569 }
ziga-lunarg1052d492022-04-03 20:12:15 +02005570 if (pCreateInfo->queryType == VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT) {
5571 const auto *primitives_generated_query_features =
5572 LvlFindInChain<VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT>(device_createinfo_pnext);
5573 if (!primitives_generated_query_features || primitives_generated_query_features->primitivesGeneratedQuery == VK_FALSE) {
5574 skip |= LogError(device, "VUID-vkCmdBeginQuery-queryType-06688",
5575 "vkCreateQueryPool(): If pCreateInfo->queryType is VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT primitivesGeneratedQuery feature must be enabled.");
5576 }
5577 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005578 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005579 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005580}
5581
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005582bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5583 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005584 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005585 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5586 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005587}
5588
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005589void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005590 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5591 VkResult result) {
5592 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005593 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005594}
5595
Mike Schuchardt2df08912020-12-15 16:28:09 -08005596void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005597 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5598 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005599 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005600 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005601 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005602}
5603
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005604void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5605 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005606 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005607 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005608 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005609}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005610
Tony-LunarG3c287f62020-12-17 12:39:49 -07005611void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005612 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005613 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005614 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005615 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005616 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005617 }
5618 }
5619}
5620
5621void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005622 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005623 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005624 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5625 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5626 }
5627}
5628
5629void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005630 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005631 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005632 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5633 if (item->second == commandPool) {
5634 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005635 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005636 ++item;
5637 }
5638 }
5639}
5640
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005641bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005642 const VkAllocationCallbacks *pAllocator,
5643 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005644 bool skip = false;
5645
5646 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005647 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005648 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005649 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5650 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005651 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005652
5653 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005654 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005655 if (flags_info) {
5656 flags = flags_info->flags;
5657 }
5658
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005659 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005660 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005661 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005662 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5663 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005664 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005665 }
5666
5667#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005668 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005669#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005670 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5671 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005672#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005673 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005674#endif
5675
5676 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005677 skip |= LogError(
5678 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005679 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5680 }
5681 if (
5682#ifdef VK_USE_PLATFORM_WIN32_KHR
5683 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5684#endif
5685 (import_memory_fd && import_memory_fd->handleType) ||
5686#ifdef VK_USE_PLATFORM_ANDROID_KHR
5687 (import_memory_ahb && import_memory_ahb->buffer) ||
5688#endif
5689 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005690 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5691 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005692 }
5693 }
5694
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005695 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5696 if (export_memory) {
5697 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5698 if (export_memory_nv) {
5699 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5700 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5701 "VkExportMemoryAllocateInfoNV");
5702 }
5703#ifdef VK_USE_PLATFORM_WIN32_KHR
5704 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5705 if (export_memory_win32_nv) {
5706 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5707 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5708 "VkExportMemoryWin32HandleInfoNV");
5709 }
5710#endif
5711 }
5712
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005713 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005714 VkBool32 capture_replay = false;
5715 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005716 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005717 if (vulkan_12_features) {
5718 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5719 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5720 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005721 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005722 if (bda_features) {
5723 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5724 buffer_device_address = bda_features->bufferDeviceAddress;
5725 }
5726 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005727 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005728 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005729 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005730 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005731 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005732 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005733 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005734 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005735 }
5736 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005737 }
5738 return skip;
5739}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005740
Jason Macnak192fa0e2019-07-26 15:07:16 -07005741bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005742 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005743 bool skip = false;
5744
5745 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5746 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5747 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005748 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005749 } else {
5750 uint32_t vertex_component_size = 0;
5751 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5752 vertex_component_size = 4;
5753 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5754 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5755 vertex_component_size = 2;
5756 }
5757 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005758 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005759 }
5760 }
5761
5762 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5763 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005764 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005765 } else {
5766 uint32_t index_element_size = 0;
5767 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5768 index_element_size = 4;
5769 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5770 index_element_size = 2;
5771 }
5772 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005773 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005774 }
5775 }
5776 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5777 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005778 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005779 }
5780 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005781 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005782 }
5783 }
5784
5785 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005786 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%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::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5793 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005794 bool skip = false;
5795
5796 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005797 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005798 }
5799 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005800 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005801 }
5802
5803 return skip;
5804}
5805
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005806bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5807 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005808 bool skip = false;
5809 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005810 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005811 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005812 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005813 }
5814 return skip;
5815}
5816
5817bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005818 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005819 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005820 bool skip = false;
5821 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005822 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5823 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5824 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005825 }
5826 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005827 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5828 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5829 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005830 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005831 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5832 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5833 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5834 }
Jason Macnak5c954952019-07-09 15:46:12 -07005835 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5836 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005837 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5838 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5839 "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 -07005840 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005841 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005842 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005843 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5844 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005845 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5846 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005847 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005848 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005849 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5850 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5851 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005852 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005853 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005854 uint64_t total_triangle_count = 0;
5855 for (uint32_t i = 0; i < info.geometryCount; i++) {
5856 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005857
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005858 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005859
Jason Macnak5c954952019-07-09 15:46:12 -07005860 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5861 continue;
5862 }
5863 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5864 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005865 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005866 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5867 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5868 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005869 }
5870 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005871 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5872 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5873 for (uint32_t i = 1; i < info.geometryCount; i++) {
5874 const VkGeometryNV &geometry = info.pGeometries[i];
5875 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005876 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005877 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5878 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005879 "info.pGeometries[0].geometryType.",
5880 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005881 }
5882 }
5883 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005884 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5885 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5886 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5887 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5888 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5889 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5890 }
5891 }
5892 skip |=
5893 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005894 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005895 return skip;
5896}
5897
Ricardo Garciaa4935972019-02-21 17:43:18 +01005898bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5899 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005900 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005901 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005902 if (pCreateInfo) {
5903 if ((pCreateInfo->compactedSize != 0) &&
5904 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005905 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5906 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5907 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5908 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005909 }
Jason Macnak5c954952019-07-09 15:46:12 -07005910
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005911 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005912 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005913 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005914 return skip;
5915}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005916
Jeff Bolz5c801d12019-10-09 10:38:45 -05005917bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5918 const VkAccelerationStructureInfoNV *pInfo,
5919 VkBuffer instanceData, VkDeviceSize instanceOffset,
5920 VkBool32 update, VkAccelerationStructureNV dst,
5921 VkAccelerationStructureNV src, VkBuffer scratch,
5922 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005923 bool skip = false;
5924
5925 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005926 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005927 }
5928
5929 return skip;
5930}
5931
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005932bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5933 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5934 VkAccelerationStructureKHR *pAccelerationStructure) const {
5935 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005936 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005937 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005938 if (!acceleration_structure_features ||
5939 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5940 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5941 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5942 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005943 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005944 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5945 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005946 (acceleration_structure_features &&
5947 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005948 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005949 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5950 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5951 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5952 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005953 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005954 if (pCreateInfo->deviceAddress &&
5955 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5956 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5957 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5958 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5959 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005960 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5961 (acceleration_structure_features &&
5962 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5963 skip |= LogError(
5964 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5965 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5966 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5967 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005968 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5969 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005970 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5971 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005972 }
sourav parmar83c31b12020-05-06 12:30:54 -07005973 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005974 return skip;
5975}
5976
Jason Macnak5c954952019-07-09 15:46:12 -07005977bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5978 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005979 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005980 bool skip = false;
5981 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005982 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5983 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005984 }
5985 return skip;
5986}
5987
sourav parmarcd5fb182020-07-17 12:58:44 -07005988bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5989 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5990 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5991 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005992 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005993 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005994 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005995 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005996 }
5997 return skip;
5998}
5999
Peter Chen85366392019-05-14 15:20:11 -04006000bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6001 uint32_t createInfoCount,
6002 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6003 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006004 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006005 bool skip = false;
6006
6007 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006008 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6009 std::stringstream msg;
6010 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6011 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6012 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006013 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006014 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Tony-LunarGce3244a2021-11-19 12:33:40 -07006015 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006016 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6017 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6018 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6019 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006020 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006021
6022 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006023 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006024 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6025 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6026 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6027 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6028 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6029 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6030 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6031 }
6032 }
6033
sourav parmarf4a78252020-04-10 13:04:21 -07006034 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6035 skip |=
6036 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6037 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6038 }
6039 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6040 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6041 skip |=
6042 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6043 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6044 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6045 }
6046 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6047 if (pCreateInfos[i].basePipelineIndex != -1) {
6048 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6049 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6050 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6051 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6052 "and pCreateInfos->basePipelineIndex is not -1.");
6053 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006054 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006055 skip |=
6056 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6057 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6058 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6059 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6060 "that element.");
6061 }
sourav parmarf4a78252020-04-10 13:04:21 -07006062 }
6063 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006064 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006065 skip |=
6066 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6067 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6068 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6069 "commands pCreateInfos parameter.");
6070 }
6071 } else {
6072 if (pCreateInfos[i].basePipelineIndex != -1) {
6073 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6074 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6075 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6076 }
6077 }
6078 }
6079 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6080 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6081 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6082 }
6083 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6084 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6085 "vkCreateRayTracingPipelinesNV: flags must not include "
6086 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6087 }
6088 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6089 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6090 "vkCreateRayTracingPipelinesNV: flags must not include "
6091 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6092 }
6093 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6094 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6095 "vkCreateRayTracingPipelinesNV: flags must not include "
6096 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6097 }
6098 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6099 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6100 "vkCreateRayTracingPipelinesNV: flags must not include "
6101 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6102 }
6103 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6104 skip |= LogError(
6105 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6106 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6107 }
6108 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6109 skip |= LogError(
6110 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6111 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6112 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006113 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6114 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6115 "vkCreateRayTracingPipelinesNV: flags must not include "
6116 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6117 }
6118 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6119 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6120 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6121 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006122 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6123 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6124 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6125 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6126 }
Peter Chen85366392019-05-14 15:20:11 -04006127 }
6128
6129 return skip;
6130}
6131
sourav parmarcd5fb182020-07-17 12:58:44 -07006132bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6133 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6134 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006135 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006136 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006137 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6138 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6139 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006140 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006141 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006142 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6143 std::stringstream msg;
6144 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6145 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006146 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006147 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006148 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6149 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6150 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6151 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6152 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6153 }
6154 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6155 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6156 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6157 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6158 }
6159 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006160 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006161 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Tony-LunarGce3244a2021-11-19 12:33:40 -07006162 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07006163 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6164 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6165 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006166 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6167 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6168 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006169 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006170 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006171 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6172 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6173 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6174 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006175 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006176 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6177 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6178 }
6179 }
sourav parmarf4a78252020-04-10 13:04:21 -07006180 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006181 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6182 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006183 }
6184 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006185 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006186 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006187 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6188 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006189 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006190 }
6191 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6192 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6193 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006194 }
6195 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6196 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6197 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6198 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6199 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6200 skip |= LogError(
6201 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006202 "vkCreateRayTracingPipelinesKHR: If flags includes "
6203 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006204 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6205 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6206 "must not be VK_SHADER_UNUSED_KHR");
6207 }
6208 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6209 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6210 skip |= LogError(
6211 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006212 "vkCreateRayTracingPipelinesKHR: If flags includes "
6213 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006214 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6215 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6216 "element must not be VK_SHADER_UNUSED_KHR");
6217 }
6218 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006219 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6220 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6221 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6222 skip |= LogError(
6223 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6224 "vkCreateRayTracingPipelinesKHR: If "
6225 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6226 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6227 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6228 }
6229 }
sourav parmarf4a78252020-04-10 13:04:21 -07006230 }
6231 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6232 if (pCreateInfos[i].basePipelineIndex != -1) {
6233 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6234 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006235 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006236 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6237 "and pCreateInfos->basePipelineIndex is not -1.");
6238 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006239 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006240 skip |=
6241 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6242 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6243 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6244 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6245 "element.");
6246 }
sourav parmarf4a78252020-04-10 13:04:21 -07006247 }
6248 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006249 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006250 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006251 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006252 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6253 ") must be a valid into the calling"
6254 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006255 pCreateInfos[i].basePipelineIndex, createInfoCount);
6256 }
6257 } else {
6258 if (pCreateInfos[i].basePipelineIndex != -1) {
6259 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006260 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006261 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6262 }
6263 }
6264 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006265 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6266 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6267 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6268 "vkCreateRayTracingPipelinesKHR: If flags includes "
6269 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6270 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006271 }
6272 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6273 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6274 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6275 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6276 "pLibraryInfo and pLibraryInterface must be NULL.");
6277 }
6278 if (pCreateInfos[i].pLibraryInfo) {
6279 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6280 if (pCreateInfos[i].stageCount == 0) {
6281 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6282 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6283 "stageCount must not be 0.");
6284 }
6285 if (pCreateInfos[i].groupCount == 0) {
6286 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6287 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6288 "groupCount must not be 0.");
6289 }
6290 } else {
6291 if (pCreateInfos[i].pLibraryInterface == NULL) {
6292 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6293 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6294 "is greater than 0, its "
6295 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006296 }
6297 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006298 }
6299 if (pCreateInfos[i].pLibraryInterface) {
6300 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6301 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6302 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6303 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6304 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6305 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006306 }
6307 if (deferredOperation != VK_NULL_HANDLE) {
6308 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6309 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6310 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6311 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006312 }
6313 }
ziga-lunargdea76582021-09-17 14:38:08 +02006314 if (pCreateInfos[i].pDynamicState) {
6315 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6316 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6317 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6318 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6319 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6320 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6321 }
6322 }
6323 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006324 }
6325
6326 return skip;
6327}
6328
Mike Schuchardt21638df2019-03-16 10:52:02 -07006329#ifdef VK_USE_PLATFORM_WIN32_KHR
6330bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6331 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006332 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006333 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006334 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006335 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006336 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006337 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006338 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006339 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006340 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006341 skip |=
6342 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006343 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006344 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6345 skip |= validate_struct_type(
6346 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6347 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6348 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6349 if (pSurfaceInfo != NULL) {
6350 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6351 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6352 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6353
6354 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6355 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6356 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6357 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006358 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6359 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006360
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006361 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6362 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6363 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6364 "VK_GOOGLE_surfaceless_query is not enabled.");
6365 }
6366
Mike Schuchardt21638df2019-03-16 10:52:02 -07006367 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6368 }
6369 return skip;
6370}
6371#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006372
6373bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6374 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006375 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006376 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6377 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006378 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006379 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6380 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6381 }
6382 return skip;
6383}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006384
6385bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006386 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006387 bool skip = false;
6388
6389 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006390 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006391 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006392 }
6393
6394 return skip;
6395}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006396
6397bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006398 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006399 bool skip = false;
6400
6401 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006402 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6403 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006404 }
6405
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006406 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006407 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006408 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6409 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006410 }
6411
6412 return skip;
6413}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006414
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006415bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6416 uint32_t bindingCount, const VkBuffer *pBuffers,
6417 const VkDeviceSize *pOffsets) const {
6418 bool skip = false;
6419 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006420 skip |=
6421 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6422 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6423 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006424 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6425 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006426 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6427 ") must be less than "
6428 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006429 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6430 }
6431
Jeff Bolz165818a2020-05-08 11:19:03 -05006432 for (uint32_t i = 0; i < bindingCount; ++i) {
6433 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006434 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006435 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006436 skip |=
6437 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6438 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006439 } else {
6440 if (pOffsets[i] != 0) {
6441 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006442 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6443 "] is not 0",
6444 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006445 }
6446 }
6447 }
6448 }
6449
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006450 return skip;
6451}
6452
Mark Lobodzinski84988402019-09-11 15:27:30 -06006453bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006454 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006455 bool skip = false;
6456 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006457 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6458 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006459 }
6460 return skip;
6461}
6462
6463bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006464 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006465 bool skip = false;
6466 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006467 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6468 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006469 }
6470 return skip;
6471}
Petr Kraus3d720392019-11-13 02:52:39 +01006472
6473bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6474 VkSemaphore semaphore, VkFence fence,
6475 uint32_t *pImageIndex) const {
6476 bool skip = false;
6477
6478 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006479 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6480 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006481 }
6482
6483 return skip;
6484}
6485
6486bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6487 uint32_t *pImageIndex) const {
6488 bool skip = false;
6489
6490 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006491 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6492 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006493 }
6494
6495 return skip;
6496}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006497
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006498bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6499 uint32_t firstBinding, uint32_t bindingCount,
6500 const VkBuffer *pBuffers,
6501 const VkDeviceSize *pOffsets,
6502 const VkDeviceSize *pSizes) const {
6503 bool skip = false;
6504
6505 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6506 for (uint32_t i = 0; i < bindingCount; ++i) {
6507 if (pOffsets[i] & 3) {
6508 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6509 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6510 }
6511 }
6512
6513 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6514 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6515 "%s: The firstBinding(%" PRIu32
6516 ") index is greater than or equal to "
6517 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6518 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6519 }
6520
6521 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6522 skip |=
6523 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6524 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6525 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6526 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6527 }
6528
6529 for (uint32_t i = 0; i < bindingCount; ++i) {
6530 // pSizes is optional and may be nullptr.
6531 if (pSizes != nullptr) {
6532 if (pSizes[i] != VK_WHOLE_SIZE &&
6533 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6534 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6535 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6536 ") is not VK_WHOLE_SIZE and is greater than "
6537 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6538 cmd_name, i, pSizes[i]);
6539 }
6540 }
6541 }
6542
6543 return skip;
6544}
6545
6546bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6547 uint32_t firstCounterBuffer,
6548 uint32_t counterBufferCount,
6549 const VkBuffer *pCounterBuffers,
6550 const VkDeviceSize *pCounterBufferOffsets) const {
6551 bool skip = false;
6552
6553 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6554 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6555 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6556 "%s: The firstCounterBuffer(%" PRIu32
6557 ") index is greater than or equal to "
6558 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6559 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6560 }
6561
6562 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6563 skip |=
6564 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6565 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6566 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6567 cmd_name, firstCounterBuffer, counterBufferCount,
6568 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6569 }
6570
6571 return skip;
6572}
6573
6574bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6575 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6576 const VkBuffer *pCounterBuffers,
6577 const VkDeviceSize *pCounterBufferOffsets) const {
6578 bool skip = false;
6579
6580 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6581 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6582 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6583 "%s: The firstCounterBuffer(%" PRIu32
6584 ") index is greater than or equal to "
6585 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6586 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6587 }
6588
6589 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6590 skip |=
6591 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6592 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6593 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6594 cmd_name, firstCounterBuffer, counterBufferCount,
6595 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6596 }
6597
6598 return skip;
6599}
6600
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006601bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6602 uint32_t firstInstance, VkBuffer counterBuffer,
6603 VkDeviceSize counterBufferOffset,
6604 uint32_t counterOffset, uint32_t vertexStride) const {
6605 bool skip = false;
6606
6607 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006608 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6609 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6610 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6611 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006612 }
6613
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006614 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006615 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006616 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006617 }
6618
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006619 return skip;
6620}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006621
6622bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6623 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6624 const VkAllocationCallbacks *pAllocator,
6625 VkSamplerYcbcrConversion *pYcbcrConversion,
6626 const char *apiName) const {
6627 bool skip = false;
6628
6629 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006630 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006631 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006632 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006633 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6634 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006635 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006636 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006637 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006638
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006639#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006640 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006641 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006642#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006643 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006644#endif
6645
sfricke-samsung1a72f942020-07-25 12:09:18 -07006646 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006647
6648 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006649 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006650 const VkComponentMapping components = pCreateInfo->components;
6651 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6652 if (FormatIsXChromaSubsampled(format) == true) {
6653 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6654 skip |=
6655 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006656 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6657 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006658 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006659 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006660
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006661 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6662 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6663 skip |= LogError(
6664 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6665 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6666 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6667 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6668 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006669
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006670 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6671 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6672 skip |=
6673 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006674 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6675 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006676 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006677 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006678
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006679 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6680 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6681 skip |=
6682 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006683 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6684 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006685 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006686 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006687
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006688 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006689 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6690 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6691 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006692 skip |=
6693 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006694 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6695 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006696 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6697 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006698 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006699 }
6700
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006701 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6702 // Checks same VU multiple ways in order to give a more useful error message
6703 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6704 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6705 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6706 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6707 skip |= LogError(
6708 device, vuid,
6709 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6710 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6711 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6712 string_VkComponentSwizzle(components.b));
6713 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006714
sfricke-samsunged028b02021-09-06 23:14:51 -07006715 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6716 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006717 // 3 = no [a]
6718 // 2 = no [b,a]
6719 // 1 = no [g,b,a]
6720 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006721 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006722
sfricke-samsunged028b02021-09-06 23:14:51 -07006723 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6724 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006725 skip |= LogError(device, vuid,
6726 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6727 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6728 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6729 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006730 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006731 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6732 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6733 skip |= LogError(device, vuid,
6734 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6735 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6736 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6737 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6738 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006739 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006740 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6741 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6742 skip |= LogError(device, vuid,
6743 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6744 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6745 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6746 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6747 string_VkComponentSwizzle(components.b));
6748 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006749 }
6750 }
6751
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006752 return skip;
6753}
6754
6755bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6756 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6757 const VkAllocationCallbacks *pAllocator,
6758 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6759 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6760 "vkCreateSamplerYcbcrConversion");
6761}
6762
6763bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6764 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6765 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6766 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6767 "vkCreateSamplerYcbcrConversionKHR");
6768}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006769
6770bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6771 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6772 bool skip = false;
6773 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6774 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6775
6776 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006777 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6778 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6779 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6780 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6781 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006782 }
6783 return skip;
6784}
sourav parmara96ab1a2020-04-25 16:28:23 -07006785
6786bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006787 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006788 bool skip = false;
6789 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6790 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6791 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6792 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006793 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006794 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6795 skip |= LogError(
6796 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6797 "vkCopyAccelerationStructureToMemoryKHR: The "
6798 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6799 }
6800 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6801 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6802 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6803 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6804 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6805 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006806 return skip;
6807}
6808
6809bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6810 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6811 bool skip = false;
6812 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6813 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6814 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6815 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6816 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006817 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6818 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006819 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006820 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006821 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006822 return skip;
6823}
6824
6825bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6826 const char *api_name) const {
6827 bool skip = false;
6828 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6829 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6830 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6831 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6832 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6833 api_name);
6834 }
6835 return skip;
6836}
6837
6838bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006839 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006840 bool skip = false;
6841 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006842 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006843 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006844 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006845 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6846 "vkCopyAccelerationStructureKHR: The "
6847 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006848 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006849 return skip;
6850}
6851
6852bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6853 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6854 bool skip = false;
6855 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6856 return skip;
6857}
6858
6859bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006860 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006861 bool skip = false;
6862 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006863 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006864 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6865 }
6866 return skip;
6867}
6868
6869bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006870 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006871 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006872 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006873 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006874 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6875 skip |= LogError(
6876 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6877 "vkCopyMemoryToAccelerationStructureKHR: The "
6878 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006879 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006880 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6881 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006882 return skip;
6883}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006884
sourav parmara96ab1a2020-04-25 16:28:23 -07006885bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6886 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6887 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006888 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006889 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6890 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006891 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006892 pInfo->src.deviceAddress);
6893 }
sourav parmar83c31b12020-05-06 12:30:54 -07006894 return skip;
6895}
6896bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6897 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6898 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6899 bool skip = false;
6900 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6901 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6902 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6903 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6904 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6905 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6906 }
6907 return skip;
6908}
6909bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6910 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6911 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6912 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006913 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006914 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6915 skip |= LogError(
6916 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6917 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6918 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6919 }
sourav parmar83c31b12020-05-06 12:30:54 -07006920 if (dataSize < accelerationStructureCount * stride) {
6921 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6922 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006923 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006924 dataSize, accelerationStructureCount, stride);
6925 }
6926 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6927 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6928 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6929 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6930 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6931 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6932 }
6933 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6934 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6935 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6936 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6937 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6938 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6939 stride);
6940 }
6941 }
6942 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6943 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6944 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6945 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6946 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6947 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6948 stride);
6949 }
6950 }
sourav parmar83c31b12020-05-06 12:30:54 -07006951 return skip;
6952}
6953bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6954 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6955 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006956 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006957 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6958 skip |= LogError(
6959 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6960 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6961 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006962 }
6963 return skip;
6964}
6965
6966bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006967 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6968 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6969 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6970 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006971 uint32_t width, uint32_t height, uint32_t depth) const {
6972 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006973 // RayGen
6974 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6975 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6976 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006977 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006978 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6979 0) {
6980 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6981 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6982 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6983 }
6984 // Callable
6985 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6986 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6987 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6988 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006989 }
6990 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6991 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6992 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006993 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6994 }
6995 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6996 0) {
6997 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6998 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6999 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007000 }
7001 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007002 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7003 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7004 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7005 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007006 }
7007 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7008 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007009 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7010 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007011 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007012 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7013 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7014 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7015 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7016 }
sourav parmar83c31b12020-05-06 12:30:54 -07007017 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007018 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7019 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7020 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7021 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007022 }
7023 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7024 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7025 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007026 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7027 }
7028 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7029 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7030 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7031 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7032 }
7033 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
7034 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
7035 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7036 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7037 }
7038 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7039 skip |=
7040 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
7041 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7042 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007043 }
7044
sourav parmarcd5fb182020-07-17 12:58:44 -07007045 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7046 skip |=
7047 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
7048 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7049 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7050 }
7051
7052 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7053 skip |=
7054 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
7055 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7056 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007057 }
7058 return skip;
7059}
7060
sourav parmarcd5fb182020-07-17 12:58:44 -07007061bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7062 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7063 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7064 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007065 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007066 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007067 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7068 skip |= LogError(
7069 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7070 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7071 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007072 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007073 // RayGen
7074 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7075 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7076 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007077 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007078 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7079 0) {
7080 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7081 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7082 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7083 }
7084 // Callabe
7085 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7086 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7087 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7088 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007089 }
7090 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7091 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007092 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7093 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7094 }
7095 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7096 0) {
7097 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7098 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7099 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007100 }
7101 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007102 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7103 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7104 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7105 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007106 }
7107 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7108 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007109 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7110 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007111 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007112 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7113 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7114 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7115 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7116 }
sourav parmar83c31b12020-05-06 12:30:54 -07007117 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007118 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7119 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7120 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7121 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007122 }
7123 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7124 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007125 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7126 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7127 }
7128 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7129 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7130 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7131 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007132 }
7133
sourav parmarcd5fb182020-07-17 12:58:44 -07007134 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7135 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7136 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007137 }
7138 return skip;
7139}
7140bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7141 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7142 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7143 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7144 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7145 uint32_t width, uint32_t height, uint32_t depth) const {
7146 bool skip = false;
7147 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7148 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7149 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7150 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7151 }
7152 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7153 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7154 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7155 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7156 }
7157 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7158 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7159 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7160 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7161 }
7162
7163 // hitShader
7164 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7165 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7166 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7167 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7168 }
7169 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7170 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7171 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7172 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7173 }
7174 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7175 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7176 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7177 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7178 }
7179
7180 // missShader
7181 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7182 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7183 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7184 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7185 }
7186 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7187 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7188 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7189 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7190 }
7191 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7192 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7193 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7194 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7195 }
7196
7197 // raygenShader
7198 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7199 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7200 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007201 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7202 }
7203 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7204 skip |=
7205 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7206 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7207 }
7208 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7209 skip |=
7210 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7211 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7212 }
7213 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7214 skip |=
7215 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7216 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007217 }
7218 return skip;
7219}
7220
sourav parmar83c31b12020-05-06 12:30:54 -07007221bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007222 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7223 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007224 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007225 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7226 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007227 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7228 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007229 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007230 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7231 }
7232 return skip;
7233}
7234
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007235bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7236 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007237 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007238 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007239
7240 if (!physical_device_features.multiViewport) {
7241 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007242 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7243 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007244 viewportCount);
7245 }
7246 } else { // multiViewport enabled
7247 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007248 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7249 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007250 ") must "
7251 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007252 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007253 }
7254 }
7255
7256 if (pViewports) {
7257 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7258 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007259 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007260 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007261 }
7262 }
7263
7264 return skip;
7265}
7266
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007267bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7268 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007269 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007270 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7271 return skip;
7272}
7273
7274bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7275 const VkViewport *pViewports) const {
7276 bool skip = false;
7277 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7278 return skip;
7279}
7280
7281bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7282 const VkRect2D *pScissors, bool is_ext) const {
7283 bool skip = false;
7284 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007285
7286 if (!physical_device_features.multiViewport) {
7287 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007288 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7289 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007290 ") must "
7291 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007292 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007293 }
7294 } else { // multiViewport enabled
7295 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007296 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7297 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007298 ") must "
7299 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007300 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007301 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007302 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7303 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007304 ") must "
7305 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007306 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007307 }
7308 }
7309
7310 if (pScissors) {
7311 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7312 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7313
7314 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007315 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7316 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007317 }
7318
7319 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007320 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7321 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007322 }
7323
7324 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7325 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007326 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7327 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7328 "] will overflow int32_t.",
7329 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007330 }
7331
7332 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7333 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007334 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7335 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7336 "] will overflow int32_t.",
7337 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7338 }
7339 }
7340 }
7341
7342 return skip;
7343}
7344
7345bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7346 const VkRect2D *pScissors) const {
7347 bool skip = false;
7348 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7349 return skip;
7350}
7351
7352bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7353 const VkRect2D *pScissors) const {
7354 bool skip = false;
7355 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7356 return skip;
7357}
7358
7359bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7360 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7361 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7362 bool is_2ext) const {
7363 bool skip = false;
7364 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7365 if (firstBinding >= device_limits.maxVertexInputBindings) {
7366 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7367 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7368 firstBinding, device_limits.maxVertexInputBindings);
7369 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7370 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7371 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7372 ") must be less than "
7373 "maxVertexInputBindings (%" PRIu32 ")",
7374 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7375 }
7376
7377 for (uint32_t i = 0; i < bindingCount; ++i) {
7378 if (pBuffers[i] == VK_NULL_HANDLE) {
7379 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7380 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7381 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7382 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7383 } else {
7384 if (pOffsets[i] != 0) {
7385 skip |=
7386 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7387 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7388 }
7389 }
7390 }
7391 if (pStrides) {
7392 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7393 skip |=
7394 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7395 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7396 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007397 }
7398 }
7399 }
7400
7401 return skip;
7402}
7403
7404bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7405 uint32_t bindingCount, const VkBuffer *pBuffers,
7406 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7407 const VkDeviceSize *pStrides) const {
7408 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007409 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7410 return skip;
7411}
Piers Daniell39842ee2020-07-10 16:42:33 -06007412
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007413bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7414 uint32_t bindingCount, const VkBuffer *pBuffers,
7415 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7416 const VkDeviceSize *pStrides) const {
7417 bool skip = false;
7418 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007419 return skip;
7420}
sourav parmarcd5fb182020-07-17 12:58:44 -07007421
7422bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7423 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7424 bool skip = false;
7425 for (uint32_t i = 0; i < infoCount; ++i) {
7426 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7427 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7428 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7429 }
7430 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7431 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7432 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7433 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7434 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7435 api_name);
7436 }
7437 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7438 skip |=
7439 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7440 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7441 }
7442 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7443 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7444 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7445 }
7446 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7447 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7448 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7449 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7450 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7451 api_name);
7452 }
7453 if (pInfos[i].pGeometries) {
7454 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7455 skip |= validate_ranged_enum(
7456 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7457 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7458 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7459 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007460 skip |= validate_struct_type(
7461 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7462 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7463 &(pInfos[i].pGeometries[j].geometry.triangles),
7464 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7465 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7466 skip |= validate_struct_pnext(
7467 api_name,
7468 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7469 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7470 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7471 skip |=
7472 validate_ranged_enum(api_name,
7473 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7474 ParameterName::IndexVector{i, j}),
7475 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7476 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7477 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7478 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7479 &pInfos[i].pGeometries[j].geometry.triangles,
7480 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7481 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7482 skip |= validate_ranged_enum(
7483 api_name,
7484 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7485 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7486 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7487
7488 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7489 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7490 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7491 }
7492 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7493 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7494 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7495 skip |=
7496 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7497 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7498 api_name);
7499 }
7500 }
7501 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7502 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7503 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7504 &pInfos[i].pGeometries[j].geometry.instances,
7505 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7506 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7507 skip |= validate_struct_type(
7508 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7509 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7510 &(pInfos[i].pGeometries[j].geometry.instances),
7511 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7512 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7513 skip |= validate_struct_pnext(
7514 api_name,
7515 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7516 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7517 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7518
7519 skip |= validate_bool32(api_name,
7520 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7521 ParameterName::IndexVector{i, j}),
7522 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7523 }
7524 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7525 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7526 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7527 &pInfos[i].pGeometries[j].geometry.aabbs,
7528 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7529 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7530 skip |= validate_struct_type(
7531 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7532 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7533 &(pInfos[i].pGeometries[j].geometry.aabbs),
7534 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7535 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7536 skip |= validate_struct_pnext(
7537 api_name,
7538 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7539 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7540 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7541 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7542 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7543 "(%s):stride must be less than or equal to 2^32-1", api_name);
7544 }
7545 }
7546 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7547 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7548 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7549 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7550 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7551 api_name);
7552 }
7553 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7554 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7555 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7556 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7557 "of elements of"
7558 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7559 api_name);
7560 }
7561 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7562 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7563 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7564 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7565 api_name);
7566 }
7567 }
7568 }
7569 }
7570 if (pInfos[i].ppGeometries != NULL) {
7571 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7572 skip |= validate_ranged_enum(
7573 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7574 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7575 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7576 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007577 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7578 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7579 &pInfos[i].ppGeometries[j]->geometry.triangles,
7580 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7581 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7582 skip |= validate_struct_type(
7583 api_name,
7584 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7585 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7586 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7587 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7588 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7589 skip |= validate_struct_pnext(
7590 api_name,
7591 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7592 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7593 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7594 skip |= validate_ranged_enum(api_name,
7595 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7596 ParameterName::IndexVector{i, j}),
7597 "VkFormat", AllVkFormatEnums,
7598 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7599 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7600 skip |= validate_ranged_enum(api_name,
7601 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7602 ParameterName::IndexVector{i, j}),
7603 "VkIndexType", AllVkIndexTypeEnums,
7604 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7605 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7606 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7607 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7608 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7609 }
7610 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7611 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7612 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7613 skip |=
7614 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7615 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7616 api_name);
7617 }
7618 }
7619 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7620 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7621 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7622 &pInfos[i].ppGeometries[j]->geometry.instances,
7623 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7624 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7625 skip |= validate_struct_type(
7626 api_name,
7627 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7628 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7629 &(pInfos[i].ppGeometries[j]->geometry.instances),
7630 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7631 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7632 skip |= validate_struct_pnext(
7633 api_name,
7634 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7635 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7636 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7637 skip |= validate_bool32(api_name,
7638 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7639 ParameterName::IndexVector{i, j}),
7640 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7641 }
7642 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7643 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7644 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7645 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7646 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7647 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7648 skip |= validate_struct_type(
7649 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7650 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7651 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7652 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7653 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7654 skip |= validate_struct_pnext(
7655 api_name,
7656 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7657 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7658 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7659 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7660 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7661 "(%s):stride must be less than or equal to 2^32-1", api_name);
7662 }
7663 }
7664 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7665 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7666 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7667 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7668 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7669 api_name);
7670 }
7671 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7672 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7673 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7674 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7675 "of elements of"
7676 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7677 api_name);
7678 }
7679 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7680 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7681 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7682 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7683 api_name);
7684 }
7685 }
7686 }
7687 }
7688 }
7689 return skip;
7690}
7691bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7692 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7693 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7694 bool skip = false;
7695 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7696 for (uint32_t i = 0; i < infoCount; ++i) {
7697 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7698 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7699 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7700 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7701 "scratchData.deviceAddress member must be a multiple of "
7702 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7703 }
7704 for (uint32_t k = 0; k < infoCount; ++k) {
7705 if (i == k) continue;
7706 bool found = false;
7707 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007708 skip |=
7709 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7710 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7711 ") of pInfos must "
7712 "not be "
7713 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7714 ") of pInfos.",
7715 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007716 found = true;
7717 }
7718 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007719 skip |=
7720 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7721 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7722 ") of pInfos must "
7723 "not be "
7724 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7725 ") of pInfos.",
7726 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007727 found = true;
7728 }
7729 if (found) break;
7730 }
7731 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7732 if (pInfos[i].pGeometries) {
7733 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7734 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7735 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7736 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7737 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7738 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7739 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7740 }
7741 } else {
7742 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7743 skip |=
7744 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7745 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7746 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7747 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7748 }
7749 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007750 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007751 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7752 skip |= LogError(
7753 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7754 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7755 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7756 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007757 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7758 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007759 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7760 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7761 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7762 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7763 }
7764 }
7765 } else if (pInfos[i].ppGeometries) {
7766 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7767 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7768 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7769 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7770 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7771 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7772 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7773 }
7774 } else {
7775 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7776 skip |=
7777 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7778 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7779 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7780 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7781 }
7782 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007783 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007784 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7785 skip |= LogError(
7786 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7787 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7788 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7789 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007790 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7791 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007792 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7793 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7794 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7795 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7796 }
7797 }
7798 }
7799 }
7800 }
7801 return skip;
7802}
7803
7804bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7805 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7806 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7807 const uint32_t *const *ppMaxPrimitiveCounts) const {
7808 bool skip = false;
7809 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7810 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007811 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007812 if (!ray_tracing_acceleration_structure_features ||
7813 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7814 skip |= LogError(
7815 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7816 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7817 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7818 }
7819 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007820 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7821 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7822 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7823 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7824 "scratchData.deviceAddress member must be a multiple of "
7825 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7826 }
7827 for (uint32_t k = 0; k < infoCount; ++k) {
7828 if (i == k) continue;
7829 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007830 skip |= LogError(
7831 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7832 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7833 ") "
7834 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7835 "any other element [%" PRIu32 ") of pInfos.",
7836 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007837 break;
7838 }
7839 }
7840 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7841 if (pInfos[i].pGeometries) {
7842 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7843 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7844 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7845 skip |= LogError(
7846 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7847 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7848 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7849 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7850 }
7851 } else {
7852 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7853 skip |= LogError(
7854 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7855 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7856 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7857 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7858 }
7859 }
7860 }
7861 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7862 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7863 skip |= LogError(
7864 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7865 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7866 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7867 }
7868 }
7869 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7870 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7871 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7872 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7873 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7874 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7875 }
7876 }
7877 } else if (pInfos[i].ppGeometries) {
7878 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7879 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7880 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7881 skip |= LogError(
7882 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7883 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7884 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7885 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7886 }
7887 } else {
7888 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7889 skip |= LogError(
7890 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7891 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7892 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7893 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7894 }
7895 }
7896 }
7897 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7898 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7899 skip |= LogError(
7900 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7901 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7902 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7903 }
7904 }
7905 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7906 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7907 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7908 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7909 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7910 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7911 }
7912 }
7913 }
7914 }
7915 }
7916 return skip;
7917}
7918
7919bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7920 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7921 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7922 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7923 bool skip = false;
7924 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7925 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007926 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007927 if (!ray_tracing_acceleration_structure_features ||
7928 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7929 skip |=
7930 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7931 "vkBuildAccelerationStructuresKHR: The "
7932 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7933 }
7934 for (uint32_t i = 0; i < infoCount; ++i) {
7935 for (uint32_t j = 0; j < infoCount; ++j) {
7936 if (i == j) continue;
7937 bool found = false;
7938 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007939 skip |=
7940 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7941 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
7942 ") of pInfos must "
7943 "not be "
7944 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7945 ") of pInfos.",
7946 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007947 found = true;
7948 }
7949 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007950 skip |=
7951 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7952 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
7953 ") of pInfos must "
7954 "not be "
7955 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7956 ") of pInfos.",
7957 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007958 found = true;
7959 }
7960 if (found) break;
7961 }
7962 }
7963 return skip;
7964}
7965
7966bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7967 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7968 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7969 bool skip = false;
7970 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7971 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007972 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7973 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01007974 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
7975 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007976 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01007977 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
7978 }
7979 if (pBuildInfo != nullptr) {
7980 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
7981 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
7982 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
7983 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
7984 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007985 }
7986 return skip;
7987}
sfricke-samsungecafb192021-01-17 08:21:14 -08007988
Piers Daniellcb6d8032021-04-19 18:51:26 -06007989bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7990 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7991 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7992 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7993 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06007994 const auto *vertex_attribute_divisor_features =
7995 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7996
Piers Daniellcb6d8032021-04-19 18:51:26 -06007997 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7998 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7999 skip |=
8000 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8001 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8002 }
8003
8004 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8005 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8006 skip |= LogError(
8007 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8008 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8009 }
8010
8011 // VUID-vkCmdSetVertexInputEXT-binding-04793
8012 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8013 bool binding_found = false;
8014 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8015 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8016 binding_found = true;
8017 break;
8018 }
8019 }
8020 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008021 skip |= LogError(
8022 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8023 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008024 }
8025 }
8026
8027 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8028 if (vertexBindingDescriptionCount > 1) {
8029 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8030 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8031 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8032 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8033 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008034 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8035 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008036 }
8037 }
8038 }
8039 }
8040
8041 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8042 if (vertexAttributeDescriptionCount > 1) {
8043 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8044 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8045 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8046 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8047 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008048 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8049 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008050 }
8051 }
8052 }
8053 }
8054
8055 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8056 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8057 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008058 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8059 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8060 "].binding is greater than maxVertexInputBindings",
8061 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008062 }
8063
8064 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8065 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008066 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8067 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8068 "].stride is greater than maxVertexInputBindingStride",
8069 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008070 }
8071
8072 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8073 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8074 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8075 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008076 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8077 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008078 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8079 binding);
8080 }
8081
8082 if (pVertexBindingDescriptions[binding].divisor > 1) {
8083 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8084 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8085 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008086 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8087 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008088 "vertexAttributeInstanceRateDivisor is not enabled",
8089 binding);
8090 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008091 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008092 if (pVertexBindingDescriptions[binding].divisor >
8093 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008094 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8095 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8096 "].divisor is greater than maxVertexAttribDivisor",
8097 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008098 }
8099
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008100 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008101 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008102 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8103 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8104 "].divisor is greater than 1 but inputRate "
8105 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8106 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008107 }
8108 }
8109 }
8110 }
8111
8112 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008113 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008114 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008115 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8116 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8117 "].location is greater than maxVertexInputAttributes",
8118 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008119 }
8120
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008121 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008122 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008123 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8124 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8125 "].binding is greater than maxVertexInputBindings",
8126 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008127 }
8128
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008129 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008130 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008131 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8132 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8133 "].offset is greater than maxVertexInputAttributeOffset",
8134 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008135 }
8136
8137 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8138 VkFormatProperties properties;
8139 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8140 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8141 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008142 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8143 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008144 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8145 attribute);
8146 }
8147 }
8148
8149 return skip;
8150}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008151
8152bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8153 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8154 const void *pValues) const {
8155 bool skip = false;
8156 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8157 // Check that offset + size don't exceed the max.
8158 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8159 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008160 skip |=
8161 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8162 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8163 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008164 }
8165 if (size > max_push_constants_size - offset) {
8166 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008167 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8168 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008169 offset, size, max_push_constants_size);
8170 }
8171
8172 // size needs to be non-zero and a multiple of 4.
8173 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008174 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8175 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008176 }
8177
8178 // offset needs to be a multiple of 4.
8179 if ((offset & 0x3) != 0) {
8180 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008181 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008182 }
8183 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008184}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008185
8186bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8187 uint32_t srcCacheCount,
8188 const VkPipelineCache *pSrcCaches) const {
8189 bool skip = false;
8190 if (pSrcCaches) {
8191 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8192 if (pSrcCaches[index0] == dstCache) {
8193 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8194 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8195 report_data->FormatHandle(dstCache).c_str());
8196 break;
8197 }
8198 }
8199 }
8200 return skip;
8201}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008202
8203bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8204 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8205 uint32_t rangeCount,
8206 const VkImageSubresourceRange *pRanges) const {
8207 bool skip = false;
8208 if (!pColor) {
8209 skip |=
8210 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8211 }
8212 return skip;
8213}
8214
8215bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8216 const VkRenderPassBeginInfo *const rp_begin) const {
8217 bool skip = false;
8218 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8219 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8220 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008221 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008222 func_name, rp_begin->clearValueCount);
8223 }
8224 return skip;
8225}
8226
8227bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8228 VkSubpassContents) const {
8229 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8230 return skip;
8231}
8232
8233bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8234 const VkRenderPassBeginInfo *pRenderPassBegin,
8235 const VkSubpassBeginInfo *) const {
8236 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8237 return skip;
8238}
8239
8240bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8241 const VkSubpassBeginInfo *) const {
8242 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8243 return skip;
8244}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008245
8246bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8247 uint32_t firstDiscardRectangle,
8248 uint32_t discardRectangleCount,
8249 const VkRect2D *pDiscardRectangles) const {
8250 bool skip = false;
8251
8252 if (pDiscardRectangles) {
8253 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8254 const int64_t x_sum =
8255 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8256 if (x_sum > std::numeric_limits<int32_t>::max()) {
8257 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8258 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8259 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8260 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8261 }
8262
8263 const int64_t y_sum =
8264 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8265 if (y_sum > std::numeric_limits<int32_t>::max()) {
8266 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8267 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8268 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8269 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8270 }
8271 }
8272 }
8273
8274 return skip;
8275}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008276
8277bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8278 uint32_t queryCount, size_t dataSize, void *pData,
8279 VkDeviceSize stride, VkQueryResultFlags flags) const {
8280 bool skip = false;
8281
8282 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8283 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8284 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8285 }
8286
8287 return skip;
8288}
ziga-lunargcf340c42021-08-19 00:13:38 +02008289
8290bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8291 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8292 bool skip = false;
8293
8294 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8295 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8296 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8297 ") is not a multiple of 4.",
8298 pConditionalRenderingBegin->offset);
8299 }
8300
8301 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008302}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008303
8304bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8305 VkSurfaceKHR surface,
8306 uint32_t *pSurfaceFormatCount,
8307 VkSurfaceFormatKHR *pSurfaceFormats) const {
8308 bool skip = false;
8309 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8310 skip |= LogError(
8311 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8312 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8313 }
8314 return skip;
8315}
8316
8317bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8318 VkSurfaceKHR surface,
8319 uint32_t *pPresentModeCount,
8320 VkPresentModeKHR *pPresentModes) const {
8321 bool skip = false;
8322 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8323 skip |= LogError(
8324 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8325 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8326 }
8327 return skip;
8328}
8329
8330bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8331 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8332 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8333 bool skip = false;
8334 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8335 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8336 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8337 "VK_GOOGLE_surfaceless_query is not enabled.");
8338 }
8339 return skip;
8340}
8341
8342bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8343 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8344 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8345 bool skip = false;
8346 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8347 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8348 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8349 "VK_GOOGLE_surfaceless_query is not enabled.");
8350 }
8351 return skip;
8352}
8353
8354#ifdef VK_USE_PLATFORM_WIN32_KHR
8355bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8356 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8357 VkPresentModeKHR *pPresentModes) const {
8358 bool skip = false;
8359 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8360 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8361 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8362 "VK_GOOGLE_surfaceless_query is not enabled.");
8363 }
8364 return skip;
8365}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008366
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008367#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008368
8369bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8370 const char *func_name) const {
8371 bool skip = false;
8372
8373 if (pInfo && pInfo->pCreateInfo) {
8374 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8375 if (image_swapchain_create_info) {
8376 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8377 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8378 }
8379 }
8380
8381 return skip;
8382}
8383
8384bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8385 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8386 bool skip = false;
8387
8388 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8389
8390 return skip;
8391}
8392
8393bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8394 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8395 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8396 bool skip = false;
8397
8398 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8399
8400 return skip;
8401}