blob: 148a2cfe19656190aebe6c3583795f007a31883c [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
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001779 if (!create_info.renderPass) {
1780 if (create_info.pColorBlendState && create_info.pMultisampleState) {
1781 // Pipeline has fragment outout state
1782 const auto rendering_struct = LvlFindInChain<VkPipelineRenderingCreateInfo>(create_info.pNext);
1783 if (rendering_struct) {
1784 if ((rendering_struct->depthAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1785 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1786 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1787 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06583");
1788 }
1789
1790 if ((rendering_struct->stencilAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1791 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1792 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1793 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06584");
1794 }
1795 }
1796 }
1797 }
1798
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001799 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
1800 if (create_info.stageCount == 0) {
1801 skip |=
1802 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stageCount-06604",
1803 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "].stageCount is 0, but %s is not enabled", i,
1804 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
1805 }
1806 // TODO while PRIu32 should probably be used instead of %i below, %i is necessary due to
1807 // ParameterName::IndexFormatSpecifier
1808 skip |= validate_struct_type_array(
1809 "vkCreateGraphicsPipelines", ParameterName("pCreateInfos[%i].stageCount", ParameterName::IndexVector{i}),
1810 ParameterName("pCreateInfos[%i].pStages", ParameterName::IndexVector{i}),
1811 "VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO", pCreateInfos[i].stageCount, pCreateInfos[i].pStages,
1812 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, true, true,
1813 "VUID-VkPipelineShaderStageCreateInfo-sType-sType", "VUID-VkGraphicsPipelineCreateInfo-pStages-06600",
1814 "VUID-VkGraphicsPipelineCreateInfo-stageCount-arraylength");
1815 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1816 ParameterName("pCreateInfos[%i].pRasterizationState", ParameterName::IndexVector{i}),
1817 "VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO",
1818 pCreateInfos[i].pRasterizationState,
1819 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, true,
1820 "VUID-VkGraphicsPipelineCreateInfo-pRasterizationState-06601",
1821 "VUID-VkPipelineRasterizationStateCreateInfo-sType-sType");
1822 if (!create_info.layout) {
1823 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-layout-06602",
1824 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
1825 "].layout is VK_NULL_HANDLE, but %s is not enabled.",
1826 i, VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
1827 }
1828 }
1829
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001830 // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline"
1831 if (create_info.pDynamicState != nullptr) {
1832 const auto &dynamic_state_info = *create_info.pDynamicState;
Petr Kraus299ba622017-11-24 03:09:03 +01001833 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1834 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001835 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1836 if (has_dynamic_viewport == true) {
1837 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1838 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001839 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001840 i);
1841 }
1842 has_dynamic_viewport = true;
1843 }
1844 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1845 if (has_dynamic_scissor == true) {
1846 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1847 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001848 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001849 i);
1850 }
1851 has_dynamic_scissor = true;
1852 }
1853 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1854 if (has_dynamic_line_width == true) {
1855 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1856 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001857 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001858 i);
1859 }
1860 has_dynamic_line_width = true;
1861 }
1862 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1863 if (has_dynamic_depth_bias == true) {
1864 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1865 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001866 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001867 i);
1868 }
1869 has_dynamic_depth_bias = true;
1870 }
1871 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1872 if (has_dynamic_blend_constant == true) {
1873 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1874 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001875 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001876 i);
1877 }
1878 has_dynamic_blend_constant = true;
1879 }
1880 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1881 if (has_dynamic_depth_bounds == true) {
1882 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1883 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001884 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001885 i);
1886 }
1887 has_dynamic_depth_bounds = true;
1888 }
1889 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1890 if (has_dynamic_stencil_compare == true) {
1891 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1892 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001893 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001894 i);
1895 }
1896 has_dynamic_stencil_compare = true;
1897 }
1898 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1899 if (has_dynamic_stencil_write == true) {
1900 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1901 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001902 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001903 i);
1904 }
1905 has_dynamic_stencil_write = true;
1906 }
1907 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1908 if (has_dynamic_stencil_reference == true) {
1909 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1910 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001911 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001912 i);
1913 }
1914 has_dynamic_stencil_reference = true;
1915 }
1916 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1917 if (has_dynamic_viewport_w_scaling_nv == true) {
1918 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1919 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001920 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001921 i);
1922 }
1923 has_dynamic_viewport_w_scaling_nv = true;
1924 }
1925 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1926 if (has_dynamic_discard_rectangle_ext == true) {
1927 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1928 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001929 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001930 i);
1931 }
1932 has_dynamic_discard_rectangle_ext = true;
1933 }
1934 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1935 if (has_dynamic_sample_locations_ext == true) {
1936 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1937 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001938 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001939 i);
1940 }
1941 has_dynamic_sample_locations_ext = true;
1942 }
1943 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1944 if (has_dynamic_exclusive_scissor_nv == true) {
1945 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1946 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001947 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001948 i);
1949 }
1950 has_dynamic_exclusive_scissor_nv = true;
1951 }
1952 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1953 if (has_dynamic_shading_rate_palette_nv == true) {
1954 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1955 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001956 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001957 i);
1958 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001959 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001960 }
1961 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1962 if (has_dynamic_viewport_course_sample_order_nv == true) {
1963 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1964 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001965 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001966 i);
1967 }
1968 has_dynamic_viewport_course_sample_order_nv = true;
1969 }
1970 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1971 if (has_dynamic_line_stipple == true) {
1972 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1973 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001974 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001975 i);
1976 }
1977 has_dynamic_line_stipple = true;
1978 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001979 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1980 if (has_dynamic_cull_mode) {
1981 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1982 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001983 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001984 i);
1985 }
1986 has_dynamic_cull_mode = true;
1987 }
1988 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1989 if (has_dynamic_front_face) {
1990 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1991 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001992 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001993 i);
1994 }
1995 has_dynamic_front_face = true;
1996 }
1997 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1998 if (has_dynamic_primitive_topology) {
1999 skip |= LogError(
2000 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2001 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002002 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002003 i);
2004 }
2005 has_dynamic_primitive_topology = true;
2006 }
2007 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
2008 if (has_dynamic_viewport_with_count) {
2009 skip |= LogError(
2010 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2011 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002012 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002013 i);
2014 }
2015 has_dynamic_viewport_with_count = true;
2016 }
2017 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
2018 if (has_dynamic_scissor_with_count) {
2019 skip |= LogError(
2020 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2021 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002022 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002023 i);
2024 }
2025 has_dynamic_scissor_with_count = true;
2026 }
2027 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
2028 if (has_dynamic_vertex_input_binding_stride) {
2029 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2030 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
2031 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002032 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002033 i);
2034 }
2035 has_dynamic_vertex_input_binding_stride = true;
2036 }
2037 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
2038 if (has_dynamic_depth_test_enable) {
2039 skip |= LogError(
2040 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2041 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002042 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002043 i);
2044 }
2045 has_dynamic_depth_test_enable = true;
2046 }
2047 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
2048 if (has_dynamic_depth_write_enable) {
2049 skip |= LogError(
2050 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2051 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002052 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002053 i);
2054 }
2055 has_dynamic_depth_write_enable = true;
2056 }
2057 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
2058 if (has_dynamic_depth_compare_op) {
2059 skip |=
2060 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2061 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002062 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002063 i);
2064 }
2065 has_dynamic_depth_compare_op = true;
2066 }
2067 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
2068 if (has_dynamic_depth_bounds_test_enable) {
2069 skip |= LogError(
2070 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2071 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002072 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002073 i);
2074 }
2075 has_dynamic_depth_bounds_test_enable = true;
2076 }
2077 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
2078 if (has_dynamic_stencil_test_enable) {
2079 skip |= LogError(
2080 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2081 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002082 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002083 i);
2084 }
2085 has_dynamic_stencil_test_enable = true;
2086 }
2087 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
2088 if (has_dynamic_stencil_op) {
2089 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2090 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002091 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002092 i);
2093 }
2094 has_dynamic_stencil_op = true;
2095 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002096 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
2097 // Not allowed for graphics pipelines
2098 skip |= LogError(
2099 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
2100 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002101 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
2102 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002103 i, state_index);
2104 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002105 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
2106 if (has_patch_control_points) {
2107 skip |= LogError(
2108 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2109 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002110 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002111 i);
2112 }
2113 has_patch_control_points = true;
2114 }
2115 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2116 if (has_rasterizer_discard_enable) {
2117 skip |= LogError(
2118 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2119 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002120 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002121 i);
2122 }
2123 has_rasterizer_discard_enable = true;
2124 }
2125 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2126 if (has_depth_bias_enable) {
2127 skip |= LogError(
2128 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2129 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002130 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002131 i);
2132 }
2133 has_depth_bias_enable = true;
2134 }
2135 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2136 if (has_logic_op) {
2137 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2138 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002139 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002140 i);
2141 }
2142 has_logic_op = true;
2143 }
2144 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2145 if (has_primitive_restart_enable) {
2146 skip |= LogError(
2147 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2148 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002149 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002150 i);
2151 }
2152 has_primitive_restart_enable = true;
2153 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002154 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2155 if (has_dynamic_vertex_input) {
2156 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002157 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2158 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2159 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002160 }
2161 has_dynamic_vertex_input = true;
2162 }
Petr Kraus299ba622017-11-24 03:09:03 +01002163 }
2164 }
2165
sfricke-samsung3b944422021-01-23 02:15:19 -08002166 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2167 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2168 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002169 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2170 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002171 i);
2172 }
2173
2174 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2175 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2176 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002177 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002178 i);
2179 }
2180
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002181 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext);
2182 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) {
Tony-LunarGce3244a2021-11-19 12:33:40 -07002183 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02668",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002184 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2185 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2186 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002187 i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002188 }
2189
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002190 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002191
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002192 // Collect active stages and other information
2193 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002194 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002195 bool has_eval = false;
2196 bool has_control = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002197 if (create_info.pStages != nullptr) {
2198 for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) {
2199 active_shaders |= create_info.pStages[stage_index].stage;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002200
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002201 if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002202 has_control = true;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002203 } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002204 has_eval = true;
2205 }
2206
2207 skip |= validate_string(
2208 "vkCreateGraphicsPipelines",
2209 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002210 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", create_info.pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002211
2212 std::stringstream msg;
2213 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2214 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002215 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002216 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002217 }
2218
2219 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002220 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2221 skip |=
2222 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2223 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2224 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2225 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002226
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002227 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002228 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2229
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002230 skip |= validate_struct_pnext(
2231 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002232 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002233 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2234 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2235 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2236 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002237
2238 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002239 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002240 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2241 }
2242
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002243 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002244 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2245 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002246 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002247 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2248 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2249
2250 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002251 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002252 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002253
2254 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002255 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002256 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2257
2258 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2259 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002260 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002261 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2262
2263 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002264 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002265 }
2266
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002267 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2268 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002269
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002270 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002271 skip |=
2272 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2273 "vkCreateGraphicsPipelines: pararameter "
2274 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2275 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002276 }
2277
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002278 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002279 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002280 skip |=
2281 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2282 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2283 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2284 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2285 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002286 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2287 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002288 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002289 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2290 skip |=
2291 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2292 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002293 create_info.pVertexInputState->vertexBindingDescriptionCount,
2294 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002295 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2296
2297 skip |= validate_array(
2298 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2299 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2300 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2301 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2302
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002303 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002304 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002305 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002306 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002307 skip |= validate_ranged_enum(
2308 "vkCreateGraphicsPipelines",
2309 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2310 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002311 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002312 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2313 }
2314 }
2315
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002316 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002317 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002318 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002319 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002320 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002321 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002322 skip |= validate_ranged_enum(
2323 "vkCreateGraphicsPipelines",
2324 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2325 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002326 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002327 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002328 if (FormatIsDepthOrStencil(format)) {
2329 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2330 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2331 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2332 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002333 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2334 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002335 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2336 "alignment, replace with a color format.",
2337 i, vertex_attribute_description_index, string_VkFormat(format));
2338 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002339 }
2340 }
2341
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002342 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002343 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2344 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002345 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2346 ") is "
2347 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002348 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002349 }
2350
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002351 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002352 skip |=
2353 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2354 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002355 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2356 ") is "
2357 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002358 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002359 }
2360
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002361 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002362 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2363 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002364 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2365 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002366 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2367 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002368 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2369 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002370 "(%" PRIu32 ") is not distinct.",
2371 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002372 }
2373 vertex_bindings.insert(vertex_bind_desc.binding);
2374
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002375 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002376 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2377 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002378 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2379 "].binding (%" PRIu32
2380 ") is "
2381 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002382 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002383 }
2384
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002385 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002386 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2387 "vkCreateGraphicsPipelines: parameter "
2388 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2389 "].stride (%" PRIu32
2390 ") is greater "
2391 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2392 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002393 }
2394 }
2395
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002396 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002397 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2398 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002399 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2400 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002401 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2402 "vkCreateGraphicsPipelines: parameter "
2403 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2404 "].location (%" PRIu32 ") is not distinct.",
2405 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002406 }
2407 attribute_locations.insert(vertex_attrib_desc.location);
2408
2409 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2410 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002411 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2412 "vkCreateGraphicsPipelines: parameter "
2413 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2414 "].binding (%" PRIu32
2415 ") does not exist "
2416 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2417 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002418 }
2419
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002420 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002421 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2422 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002423 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2424 "].location (%" PRIu32
2425 ") is "
2426 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002427 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002428 }
2429
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002430 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002431 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2432 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002433 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2434 "].binding (%" PRIu32
2435 ") is "
2436 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002437 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002438 }
2439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002440 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002441 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2442 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002443 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2444 "].offset (%" PRIu32
2445 ") is "
2446 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002447 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002448 }
2449 }
2450 }
2451
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002452 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2453 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002454 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002455 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002456 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2457 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002458 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002459 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002460 i, i);
2461 } else {
2462 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2463 skip |= validate_struct_pnext(
2464 "vkCreateGraphicsPipelines",
2465 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002466 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002467 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2468 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002469
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002470 skip |= validate_reserved_flags(
2471 "vkCreateGraphicsPipelines",
2472 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002473 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002474
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002475 if (create_info.pTessellationState->patchControlPoints == 0 ||
2476 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2477 skip |=
2478 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2479 "vkCreateGraphicsPipelines: invalid parameter "
2480 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2481 ". patchControlPoints "
2482 "should be >0 and <=%" PRIu32 ".",
2483 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002484 }
2485 }
2486 }
2487
2488 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002489 if ((create_info.pRasterizationState != nullptr) &&
2490 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2491 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002492 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2493 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2494 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2495 "].pViewportState (=NULL) is not a valid pointer.",
2496 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002497 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002498 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002499
2500 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002501 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2502 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2503 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2504 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002505 }
2506
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002507 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002508 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002509 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2510 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002511 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2512 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002513 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002514 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002515 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002516 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002517 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002518 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002519 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002520 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002521 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002522 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002523 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002524 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002525
2526 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002527 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002528 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002529 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002530
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002531 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002532 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002533 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002534 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002535 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002536 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2537 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002538 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002539 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2540 const auto depth_clip_control_struct =
2541 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002542
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002543 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002544 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002545 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2546 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2547 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2548 ") is not 1.",
2549 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002550 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002551
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002552 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002553 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2554 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2555 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2556 ") is not 1.",
2557 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002558 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002559
Dave Houlton142c4cb2018-10-17 15:04:41 -06002560 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2561 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002562 skip |= LogError(
2563 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2564 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2565 "disabled, but pCreateInfos[%" PRIu32
2566 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2567 ") is not 1.",
2568 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002569 }
2570
Jeff Bolz9af91c52018-09-01 21:53:57 -05002571 if (shading_rate_image_struct &&
2572 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002573 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2574 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2575 "disabled, but pCreateInfos[%" PRIu32
2576 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2577 ") is neither 0 nor 1.",
2578 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002579 }
2580
Petr Krausa6103552017-11-16 21:21:58 +01002581 } else { // multiViewport enabled
2582 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002583 if (!has_dynamic_viewport_with_count) {
2584 skip |= LogError(
2585 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2586 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2587 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002588 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002589 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2590 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2591 "].pViewportState->viewportCount (=%" PRIu32
2592 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2593 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002594 } else if (has_dynamic_viewport_with_count) {
2595 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2596 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2597 "].pViewportState->viewportCount (=%" PRIu32
2598 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2599 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002600 }
Petr Krausa6103552017-11-16 21:21:58 +01002601
2602 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002603 if (!has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002604 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2605 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2606 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002607 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002608 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002609 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2610 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002611 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002612 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2613 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2614 "].pViewportState->scissorCount (=%" PRIu32
2615 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2616 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002617 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002618 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2619 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2620 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2621 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002622 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2623 "].pViewportState->scissorCount (=%" PRIu32
2624 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2625 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002626 }
2627 }
2628
ziga-lunarg845883b2021-07-14 15:05:00 +02002629 if (!has_dynamic_scissor && viewport_state.pScissors) {
2630 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2631 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002632
2633 if (scissor.offset.x < 0) {
2634 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2635 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2636 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2637 scissor.offset.x, i, scissor_i);
2638 }
2639
2640 if (scissor.offset.y < 0) {
2641 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2642 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2643 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2644 scissor.offset.y, i, scissor_i);
2645 }
2646
ziga-lunarg845883b2021-07-14 15:05:00 +02002647 const int64_t x_sum =
2648 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2649 if (x_sum > std::numeric_limits<int32_t>::max()) {
2650 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2651 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2652 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2653 "] will overflow int32_t.",
2654 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2655 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002656
ziga-lunarg845883b2021-07-14 15:05:00 +02002657 const int64_t y_sum =
2658 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2659 if (y_sum > std::numeric_limits<int32_t>::max()) {
2660 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2661 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2662 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2663 "] will overflow int32_t.",
2664 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2665 }
2666 }
2667 }
2668
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002669 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002670 skip |=
2671 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2672 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2673 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2674 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002675 }
2676
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002677 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002678 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2679 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2680 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2681 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2682 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002683 }
2684
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002685 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2686 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2687 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2688 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2689 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2690 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2691 skip |= LogError(
2692 device, vuid,
2693 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2694 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2695 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2696 }
Petr Krausa6103552017-11-16 21:21:58 +01002697 }
2698
Dave Houlton142c4cb2018-10-17 15:04:41 -06002699 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002700 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002701 skip |=
2702 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2703 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2704 ") must be zero or identical to pCreateInfos[%" PRIu32
2705 "].pViewportState->viewportCount (=%" PRIu32 ").",
2706 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002707 }
2708
Dave Houlton142c4cb2018-10-17 15:04:41 -06002709 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002710 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002711 skip |= LogError(
2712 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002713 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2714 "] "
2715 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2716 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2717 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002718 }
2719
Petr Krausa6103552017-11-16 21:21:58 +01002720 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002721 skip |= LogError(
2722 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002723 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2724 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002725 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2726 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002727 }
2728
2729 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002730 skip |= LogError(
2731 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002732 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2733 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002734 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2735 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002736 }
2737
Jeff Bolz3e71f782018-08-29 23:15:45 -05002738 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002739 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2740 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2741 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002742 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002743 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2744 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2745 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2746 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002747 }
2748
Jeff Bolz9af91c52018-09-01 21:53:57 -05002749 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002750 shading_rate_image_struct->viewportCount > 0 &&
2751 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002752 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002753 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002754 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002755 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2756 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002757 i, i);
2758 }
2759
Chris Mayer328d8212018-12-11 14:16:18 +01002760 if (vp_swizzle_struct) {
2761 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002762 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2763 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2764 " does "
2765 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2766 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002767 }
2768 }
2769
Petr Krausb3fcdb42018-01-09 22:09:09 +01002770 // validate the VkViewports
2771 if (!has_dynamic_viewport && viewport_state.pViewports) {
2772 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2773 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002774 const char *fn_name = "vkCreateGraphicsPipelines";
2775 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2776 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2777 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002778 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002779 }
2780 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002781
sfricke-samsung45996a42021-09-16 13:45:27 -07002782 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002783 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2784 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2785 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2786 "VK_NV_clip_space_w_scaling extension is not enabled.",
2787 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002788 }
2789
sfricke-samsung45996a42021-09-16 13:45:27 -07002790 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002791 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2792 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2793 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2794 "VK_EXT_discard_rectangles extension is not enabled.",
2795 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002796 }
2797
sfricke-samsung45996a42021-09-16 13:45:27 -07002798 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002799 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2800 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2801 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2802 "VK_EXT_sample_locations extension is not enabled.",
2803 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002804 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002805
sfricke-samsung45996a42021-09-16 13:45:27 -07002806 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002807 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2808 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2809 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2810 "VK_NV_scissor_exclusive extension is not enabled.",
2811 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002812 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002813
2814 if (coarse_sample_order_struct &&
2815 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2816 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002817 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2818 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2819 "] "
2820 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2821 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2822 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002823 }
2824
2825 if (coarse_sample_order_struct) {
2826 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002827 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002828 }
2829 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002830
2831 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2832 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002833 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2834 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2835 "] "
2836 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2837 ") "
2838 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2839 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002840 }
2841 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002842 skip |= LogError(
2843 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002844 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2845 "] "
2846 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2847 i);
2848 }
2849 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002850
2851 if (depth_clip_control_struct) {
2852 const auto *depth_clip_control_features =
2853 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2854 const bool enabled_depth_clip_control =
2855 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2856 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2857 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2858 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2859 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2860 "depthClipControl feature is not enabled. ",
2861 i);
2862 }
2863 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002864 }
2865
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002866 const bool is_frag_out_graphics_lib =
2867 graphics_lib_info &&
2868 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002869 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002870 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002871 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2872 "].pRasterizationState->rasterizerDiscardEnable "
2873 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002874 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002875 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002876 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002877 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002878 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2879 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002880 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002881 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002882 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002883
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002884 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002885 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002886 skip |= validate_struct_pnext(
2887 "vkCreateGraphicsPipelines",
2888 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002889 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002890 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2891 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002893 skip |= validate_reserved_flags(
2894 "vkCreateGraphicsPipelines",
2895 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002896 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002898 skip |= validate_bool32(
2899 "vkCreateGraphicsPipelines",
2900 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002901 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002902
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002903 skip |= validate_array(
2904 "vkCreateGraphicsPipelines",
2905 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2906 ParameterName::IndexVector{i}),
2907 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002908 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
2909 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002910
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002911 skip |= validate_flags("vkCreateGraphicsPipelines",
2912 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2913 ParameterName::IndexVector{i}),
2914 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002915 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002916 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002917
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002918 skip |= validate_bool32("vkCreateGraphicsPipelines",
2919 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
2920 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002921 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002922
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002923 skip |= validate_bool32(
2924 "vkCreateGraphicsPipelines",
2925 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002926 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002927
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002928 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002929 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
2930 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2931 "].pMultisampleState->sType must be "
2932 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002933 i);
John Zulauf7acac592017-11-06 11:15:53 -07002934 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002935 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002936 if (!physical_device_features.sampleRateShading) {
2937 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2938 "vkCreateGraphicsPipelines(): parameter "
2939 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
2940 i);
2941 }
2942 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2943 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002944 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002945 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002946
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002947 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2948 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2949 "].pMultisampleState->minSampleShading.",
2950 i);
2951 }
John Zulauf7acac592017-11-06 11:15:53 -07002952 }
2953 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002954
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002955 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002956 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002957
2958 if (line_state) {
2959 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2960 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002961 if (create_info.pMultisampleState->alphaToCoverageEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002962 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002963 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2964 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002965 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002966 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002967 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002968 if (create_info.pMultisampleState->alphaToOneEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002969 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002970 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2971 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002972 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002973 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002974 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002975 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002976 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002977 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2978 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002979 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002980 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002981 }
2982 }
2983 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2984 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2985 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002986 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002987 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
2988 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002989 "range [1,256].",
2990 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002991 }
2992 }
2993 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002994 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002995 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2996 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002997 skip |=
2998 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002999 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3000 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003001 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
3002 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003003 }
3004 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3005 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003006 skip |=
3007 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003008 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3009 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003010 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
3011 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003012 }
3013 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3014 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003015 skip |=
3016 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003017 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3018 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003019 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
3020 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003021 }
3022 if (line_state->stippledLineEnable) {
3023 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3024 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003025 skip |=
3026 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003027 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3028 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003029 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
3030 "stippledRectangularLines feature.",
3031 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003032 }
3033 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3034 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003035 skip |=
3036 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003037 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3038 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003039 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
3040 "stippledBresenhamLines feature.",
3041 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003042 }
3043 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3044 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003045 skip |=
3046 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003047 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3048 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003049 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
3050 "stippledSmoothLines feature.",
3051 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003052 }
3053 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05003054 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003055 skip |=
3056 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003057 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3058 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003059 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
3060 "stippledRectangularLines and strictLines features.",
3061 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003062 }
3063 }
3064 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003065 }
3066
Petr Krause91f7a12017-12-14 20:57:36 +01003067 bool uses_color_attachment = false;
3068 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003069 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003070 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003071 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003072 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003073 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003074 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003075 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003076 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003077 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003078 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003079 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003080 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003081 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01003082 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003083 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003084 }
3085
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003086 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003087 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003088 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003089 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003090 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003091 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003092
Mike Schuchardt00e81452021-11-29 11:11:20 -08003093 skip |=
3094 validate_flags("vkCreateGraphicsPipelines",
3095 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3096 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003097 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003098 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003099
3100 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003101 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003102 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003103 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003104
3105 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003106 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003107 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003108 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003109
3110 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003111 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003112 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003113 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003114 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003115
3116 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003117 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003118 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003119 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003120
3121 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003122 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003123 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003124 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003125
3126 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003127 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003128 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003129 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003130 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003131
3132 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003133 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003134 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003135 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003136 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003137
3138 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003139 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003140 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003141 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003142 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003143
3144 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003145 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003146 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003147 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003148 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003149
3150 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003151 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003152 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003153 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003154 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003155
3156 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003157 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003159 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003160 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003161
3162 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003163 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003164 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003165 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003166 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003167
3168 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003169 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003170 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003171 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003172 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003173
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003174 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003175 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003176 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3177 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003178 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3179 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003180 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003181
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003182 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003183 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3184 const auto *rasterization_order_attachment_access_feature =
3185 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3186 const bool rasterization_order_depth_attachment_access_feature_enabled =
3187 rasterization_order_attachment_access_feature &&
3188 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3189 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3190 skip |= LogError(
3191 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3192 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3193 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3194 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003195 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003196 }
3197
3198 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3199 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003200 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003201 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3202 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003203 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003204 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3205 }
3206 }
3207
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003208 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003209 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3210 const auto *rasterization_order_attachment_access_feature =
3211 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3212 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3213 rasterization_order_attachment_access_feature &&
3214 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3215 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3216 skip |= LogError(
3217 device,
3218 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3219 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3220 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3221 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003222 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003223 }
3224
3225 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3226 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003227 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003228 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3229 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003230 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003231 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3232 }
3233 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003234 }
3235
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003236 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003237 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3238 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003239
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003240 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3241 skip |=
3242 validate_struct_type("vkCreateGraphicsPipelines",
3243 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3244 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3245 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3246 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003247
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003248 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003249 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003250 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003251 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3252 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003253 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003254 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3255 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003256
Mike Schuchardt00e81452021-11-29 11:11:20 -08003257 skip |= validate_flags("vkCreateGraphicsPipelines",
3258 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3259 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003260 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003261 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003262
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003263 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003264 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3265 const auto *rasterization_order_attachment_access_feature =
3266 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3267 const bool rasterization_order_color_attachment_access_feature_enabled =
3268 rasterization_order_attachment_access_feature &&
3269 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3270
3271 if (!rasterization_order_color_attachment_access_feature_enabled) {
3272 skip |= LogError(
3273 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3274 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3275 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3276 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003277 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003278 }
3279
3280 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003281 skip |=
3282 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3283 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3284 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3285 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3286 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003287 }
3288 }
3289
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003290 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003291 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003292 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003293 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003294
3295 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003296 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003297 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3298 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003299 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3300 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003301
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003302 if (create_info.pColorBlendState->pAttachments != NULL) {
3303 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003304 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003305 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003306 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003307 ParameterName::IndexVector{i, attachment_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003308 create_info.pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003309
3310 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003311 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003312 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003313 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003314 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003315 create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003316 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003317
3318 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003319 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003320 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003321 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003322 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003323 create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003324 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003325
3326 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003327 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003328 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003329 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003330 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003331 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003332 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003333
3334 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003335 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003336 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003337 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003338 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003339 create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003340 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003341
3342 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003343 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003344 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003345 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003346 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003347 create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003348 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003349
3350 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003351 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003352 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003353 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003354 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003355 create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003356 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003357
3358 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003359 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003360 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003361 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003362 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003363 create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003364 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003365
3366 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3367 bool invalid = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003368 switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
ziga-lunarga283d022021-08-04 18:35:23 +02003369 case VK_BLEND_OP_ZERO_EXT:
3370 case VK_BLEND_OP_SRC_EXT:
3371 case VK_BLEND_OP_DST_EXT:
3372 case VK_BLEND_OP_SRC_OVER_EXT:
3373 case VK_BLEND_OP_DST_OVER_EXT:
3374 case VK_BLEND_OP_SRC_IN_EXT:
3375 case VK_BLEND_OP_DST_IN_EXT:
3376 case VK_BLEND_OP_SRC_OUT_EXT:
3377 case VK_BLEND_OP_DST_OUT_EXT:
3378 case VK_BLEND_OP_SRC_ATOP_EXT:
3379 case VK_BLEND_OP_DST_ATOP_EXT:
3380 case VK_BLEND_OP_XOR_EXT:
3381 case VK_BLEND_OP_INVERT_EXT:
3382 case VK_BLEND_OP_INVERT_RGB_EXT:
3383 case VK_BLEND_OP_LINEARDODGE_EXT:
3384 case VK_BLEND_OP_LINEARBURN_EXT:
3385 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3386 case VK_BLEND_OP_LINEARLIGHT_EXT:
3387 case VK_BLEND_OP_PINLIGHT_EXT:
3388 case VK_BLEND_OP_HARDMIX_EXT:
3389 case VK_BLEND_OP_PLUS_EXT:
3390 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3391 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3392 case VK_BLEND_OP_PLUS_DARKER_EXT:
3393 case VK_BLEND_OP_MINUS_EXT:
3394 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3395 case VK_BLEND_OP_CONTRAST_EXT:
3396 case VK_BLEND_OP_INVERT_OVG_EXT:
3397 case VK_BLEND_OP_RED_EXT:
3398 case VK_BLEND_OP_GREEN_EXT:
3399 case VK_BLEND_OP_BLUE_EXT:
3400 invalid = true;
3401 break;
3402 default:
3403 break;
3404 }
3405 if (invalid) {
3406 skip |= LogError(
3407 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3408 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3409 "].pColorBlendState->pAttachments[%" PRIu32
3410 "].colorBlendOp (%s) is not valid when "
3411 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3412 "VK_FALSE",
3413 i, attachment_index,
3414 string_VkBlendOp(
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003415 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp));
ziga-lunarga283d022021-08-04 18:35:23 +02003416 }
3417 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003418 }
3419 }
3420
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003421 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003422 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003423 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3424 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003425 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3426 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003427 }
3428
3429 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003430 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003431 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003432 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003434 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003435 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003436 }
3437 }
3438 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003439
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003440 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003441 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003442 if (create_info.basePipelineIndex != -1) {
3443 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003444 skip |=
3445 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003446 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3447 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003448 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003449 "and pCreateInfos->basePipelineIndex is not -1.",
3450 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003451 }
3452 }
3453
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003454 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3455 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003456 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003457 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3458 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003459 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003460 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3461 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003462 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003463 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003464 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003465 skip |=
3466 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003467 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3468 ") must be a valid"
3469 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003470 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003471 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003472 }
3473 }
3474
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003475 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003476 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003477 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003478 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003479 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3480 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3481 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3482 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003483 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003484 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003485 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003486 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003487 "pCreateInfos[%" PRIu32
3488 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003489 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3490 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003491 }
3492 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003493 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3494 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003495 (physical_device_features.fillModeNonSolid == false)) {
3496 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003497 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3498 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003499 "pCreateInfos[%" PRIu32
3500 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003501 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3502 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003503 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003504 }
Petr Kraus299ba622017-11-24 03:09:03 +01003505
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003506 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003507 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003508 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3509 "The line width state is static (pCreateInfos[%" PRIu32
3510 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3511 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3512 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003513 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003514 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003515 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003516
3517 // Validate no flags not allowed are used
3518 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003519 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003520 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3521 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003522 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3523 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003524 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003525 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3526 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003527 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003528 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3529 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003530 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3531 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003532 }
3533 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3534 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003535 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3536 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003537 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3538 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003539 }
3540 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3541 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003542 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3543 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003544 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3545 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003546 }
3547 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3548 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003549 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3550 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003551 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3552 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003553 }
3554 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3555 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003556 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3557 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003558 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3559 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003560 }
3561 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3562 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003563 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3564 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003565 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3566 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003567 }
3568 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3569 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003570 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3571 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003572 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3573 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003574 }
3575 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3576 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003577 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3578 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003579 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3580 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003581 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003582 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3583 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3584 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3585 "]->flags (0x%x) must not include "
3586 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3587 i, flags);
3588 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003589 }
3590 }
3591
3592 return skip;
3593}
3594
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003595bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3596 uint32_t createInfoCount,
3597 const VkComputePipelineCreateInfo *pCreateInfos,
3598 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003599 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003600 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003601 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003602 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003603 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003604 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003605 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003606 if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
3607 const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount;
3608 if (api_version < VK_VERSION_1_3) {
3609 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02669",
3610 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3611 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32
3612 ".",
3613 i, feedback_count);
3614 } else if ((feedback_count != 0) && (feedback_count != 1)) {
3615 skip |= LogError(
3616 device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566",
3617 "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32
3618 ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].",
3619 feedback_count, i);
3620 }
Peter Chen85366392019-05-14 15:20:11 -04003621 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003622
3623 // Make sure compute stage is selected
3624 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003625 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003626 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3627 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003628 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003629 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003630
sfricke-samsungeb549012021-04-16 01:25:51 -07003631 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3632 // Validate no flags not allowed are used
3633 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003634 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3635 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3636 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3637 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003638 }
3639 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3640 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003641 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3642 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003643 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3644 i, flags);
3645 }
3646 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3647 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003648 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3649 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003650 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3651 i, flags);
3652 }
3653 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3654 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003655 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3656 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003657 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3658 i, flags);
3659 }
3660 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3661 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003662 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3663 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003664 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3665 i, flags);
3666 }
3667 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3668 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003669 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3670 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003671 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3672 i, flags);
3673 }
3674 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3675 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003676 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3677 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003678 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3679 i, flags);
3680 }
3681 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3682 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003683 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3684 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003685 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3686 i, flags);
3687 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003688 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3689 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003690 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3691 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003692 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3693 i, flags);
3694 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003695 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3696 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003697 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3698 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003699 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3700 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003701 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003702 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3703 if (pCreateInfos[i].basePipelineIndex != -1) {
3704 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3705 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3706 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3707 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3708 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3709 i);
3710 }
3711 }
3712
3713 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3714 if (pCreateInfos[i].basePipelineIndex != -1) {
3715 skip |= LogError(
3716 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3717 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3718 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3719 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3720 i);
3721 }
3722 } else {
3723 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3724 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3725 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3726 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3727 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3728 }
3729 }
3730 }
ziga-lunargc6341372021-07-28 12:57:42 +02003731
3732 std::stringstream msg;
3733 msg << "pCreateInfos[%" << i << "].stage";
3734 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003735 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003736 return skip;
3737}
3738
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003739bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003740 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003741 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003742
3743 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003744 const auto &features = physical_device_features;
3745 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003746
John Zulauf71968502017-10-26 13:51:15 -06003747 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3748 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003749 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3750 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3751 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3752 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003753 }
3754
3755 // Anistropy cannot be enabled in sampler unless enabled as a feature
3756 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003757 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3758 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3759 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003760 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003761 }
John Zulauf71968502017-10-26 13:51:15 -06003762
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003763 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3764 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003765 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3766 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3767 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3768 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003769 }
3770 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003771 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3772 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3773 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3774 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003775 }
3776 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003777 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3778 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3779 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3780 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003781 }
3782 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3783 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3784 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3785 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003786 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3787 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3788 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3789 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3790 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3791 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003792 }
3793 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003794 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3795 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3796 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003797 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003798 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003799 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3800 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3801 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003802 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003803 }
3804
3805 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3806 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003807 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3808 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003809 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003810 if (sampler_reduction != nullptr) {
3811 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3812 skip |= LogError(
3813 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3814 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3815 }
3816 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003817 }
3818
3819 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3820 // valid VkBorderColor value
3821 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3822 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3823 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003824 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3825 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003826 }
3827
John Zulauf275805c2017-10-26 15:34:49 -06003828 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003829 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003830 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3831 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003832 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3833 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3834 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003835 }
3836 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003837
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003838 // Check for valid Lod range
3839 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003840 skip |=
3841 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3842 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003843 }
3844
3845 // Check mipLodBias to device limit
3846 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003847 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3848 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3849 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003850 }
3851
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003852 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003853 if (sampler_conversion != nullptr) {
3854 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3855 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3856 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3857 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003858 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003859 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003860 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3861 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3862 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3863 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3864 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3865 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3866 }
3867 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003868
3869 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3870 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3871 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3872 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3873 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3874 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3875 }
3876 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3877 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3878 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3879 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3880 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3881 }
3882 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3883 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3884 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3885 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3886 pCreateInfo->minLod, pCreateInfo->maxLod);
3887 }
3888 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3889 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3890 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3891 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3892 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3893 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3894 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3895 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3896 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3897 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3898 }
3899 if (pCreateInfo->anisotropyEnable) {
3900 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3901 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3902 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3903 }
3904 if (pCreateInfo->compareEnable) {
3905 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3906 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3907 "pCreateInfo->compareEnable must be VK_FALSE");
3908 }
3909 if (pCreateInfo->unnormalizedCoordinates) {
3910 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3911 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3912 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3913 }
3914 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003915
Piers Daniell833b9492021-11-20 11:47:10 -07003916 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3917 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3918 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
3919 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3920 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3921 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3922 }
3923 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
3924 if (!custom_create_info) {
3925 skip |= LogError(
3926 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3927 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3928 "struct in pNext chain.\n",
3929 string_VkBorderColor(pCreateInfo->borderColor));
3930 } else {
3931 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3932 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
3933 !FormatIsSampledInt(custom_create_info->format)) ||
3934 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3935 !FormatIsSampledFloat(custom_create_info->format)))) {
3936 skip |=
3937 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06003938 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3939 "whose type does not match\n",
3940 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07003941 ;
3942 }
3943 }
3944 }
3945
3946 const auto *border_color_component_mapping =
3947 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
3948 if (border_color_component_mapping) {
3949 const auto *border_color_swizzle_features =
3950 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
3951 bool border_color_swizzle_features_enabled =
3952 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
3953 if (!border_color_swizzle_features_enabled) {
3954 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
3955 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
3956 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06003957 }
3958 }
3959 }
3960
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003961 return skip;
3962}
3963
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003964bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
3965 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
3966 const char *func_name) const {
3967 bool skip = false;
3968
3969 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
3970 uint32_t mutable_type_count = 0;
3971 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
3972 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
3973 }
3974 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3975 if (mutable_type_count == 0) {
3976 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
3977 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3978 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
3979 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3980 "].descriptorTypeCount is 0.",
3981 func_name, i, i);
3982 }
3983 } else {
3984 if (mutable_type_count > 0) {
3985 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
3986 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3987 "].descriptorType is %s, but "
3988 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3989 "].descriptorTypeCount is not 0.",
3990 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
3991 }
3992 }
3993 }
3994
3995 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
3996 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
3997 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
3998 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
3999 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
4000 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4001 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
4002 func_name, j, k);
4003 break;
4004 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4005 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
4006 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4007 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
4008 func_name, j, k);
4009 break;
4010 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4011 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
4012 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4013 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
4014 func_name, j, k);
4015 break;
4016 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
4017 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
4018 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4019 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
4020 func_name, j, k);
4021 break;
4022 default:
4023 break;
4024 }
4025 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
4026 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
4027 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
4028 skip |=
4029 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
4030 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4031 "].pDescriptorTypes[%" PRIu32
4032 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4033 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
4034 func_name, j, k, j, l,
4035 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
4036 }
4037 }
4038 }
4039 }
4040
4041 return skip;
4042}
4043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004044bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
4045 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
4046 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004047 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004048 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004049
ziga-lunargfc6896f2021-10-15 18:46:12 +02004050 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4051 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4052 bool mutable_descriptor_type_features_enabled =
4053 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4054
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004055 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4056 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
4057 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
4058 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004059 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4060 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4061 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4062 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4063 ++descriptor_index) {
4064 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004065 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004066 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004067 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4068 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004069 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004070 }
4071 }
4072 }
4073
4074 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4075 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4076 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004077 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004078 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4079 "].descriptorCount is not 0, "
4080 "pCreateInfo->pBindings[%" PRIu32
4081 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004082 "values.",
4083 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004084 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004085
4086 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4087 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4088 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004089 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4090 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4091 "].descriptorCount is not 0 and "
4092 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4093 "].stageFlags "
4094 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4095 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004096 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004097
4098 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4099 if (!mutable_descriptor_type) {
4100 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4101 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4102 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4103 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4104 i);
4105 }
4106 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4107 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4108 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4109 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4110 "pImmutableSamplers is not NULL.",
4111 i);
4112 }
4113 if (!mutable_descriptor_type_features_enabled) {
4114 skip |= LogError(
4115 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4116 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4117 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4118 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4119 i);
4120 }
4121 }
4122
4123 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4124 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4125 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4126 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4127 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4128 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4129 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004130 }
4131 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004132
4133 if (mutable_descriptor_type) {
4134 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
4135 "vkDescriptorSetLayoutCreateInfo");
4136 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004137 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004138 if (pCreateInfo) {
4139 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4140 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4141 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4142 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4143 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4144 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4145 }
4146 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4147 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4148 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4149 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4150 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4151 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4152 }
4153 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4154 !mutable_descriptor_type_features_enabled) {
4155 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4156 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4157 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4158 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4159 }
4160 }
4161
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004162 return skip;
4163}
4164
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004165bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4166 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004167 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004168 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4169 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4170 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004171 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4172 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004173}
4174
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004175bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4176 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004177 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004178 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004179
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004180 if (pDescriptorWrites != NULL) {
4181 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4182 // descriptorCount must be greater than 0
4183 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004184 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4185 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4186 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004187 }
4188
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004189 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004190 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004191 // dstSet must be a valid VkDescriptorSet handle
4192 skip |= validate_required_handle(vkCallingFunction,
4193 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4194 pDescriptorWrites[i].dstSet);
4195 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004196
4197 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4198 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4199 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4200 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4201 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004202 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004203 if (!isPushDescriptor) {
4204 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4205 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4206 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4207 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4208 // ObjectLifetimes::ValidateDescriptorWrite.
4209 skip |= LogError(
4210 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4211 "%s(): if pDescriptorWrites[%" PRIu32
4212 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4213 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4214 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4215 vkCallingFunction, i, i);
4216 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4217 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4218 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4219 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4220 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4221 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4222 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4223 "%s(): if pDescriptorWrites[%" PRIu32
4224 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4225 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4226 "].pImageInfo must not be NULL.",
4227 vkCallingFunction, i, i);
4228 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004229 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4230 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004231 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4232 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004233 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4234 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004235 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004236 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4237 ParameterName::IndexVector{i, descriptor_index}),
4238 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004239 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004240 }
4241 }
4242 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4243 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4244 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4245 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4246 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4247 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4248 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004249 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004250 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004251 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004252 "%s(): if pDescriptorWrites[%" PRIu32
4253 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004254 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4255 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004256 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004257 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004258 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004259 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004260 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004261 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004262 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4263 ++descriptor_index) {
4264 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4265 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4266 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004267 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004268 "%s(): if pDescriptorWrites[%" PRIu32
4269 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004270 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004271 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4272 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004273 }
4274 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004275 }
4276 }
4277 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4278 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004279 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004280 }
4281
4282 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4283 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004284 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004285 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4286 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004287 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004288 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004289 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004290 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004291 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004292 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004293 }
4294 }
4295 }
4296 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4297 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004298 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004299 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4300 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004301 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004302 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004303 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004304 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004305 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004306 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004307 }
4308 }
4309 }
4310 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004311 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4312 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004313 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004314 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004315 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4316 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4317 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4318 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004319 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004320 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4321 pDescriptorWrites[i].descriptorCount);
4322 }
4323 // further checks only if we have right structtype
4324 if (pnext_struct) {
4325 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4326 skip |= LogError(
4327 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004328 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4329 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004330 ".",
4331 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004332 }
sourav parmarbcee7512020-12-28 14:34:49 -08004333 if (pnext_struct->accelerationStructureCount == 0) {
4334 skip |= LogError(device,
4335 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004336 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004337 }
4338 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004339 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004340 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4341 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4342 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4343 skip |= LogError(device,
4344 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4345 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004346 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004347 }
4348 }
4349 }
sourav parmarbcee7512020-12-28 14:34:49 -08004350 }
4351 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004352 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004353 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4354 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4355 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4356 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004357 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004358 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4359 pDescriptorWrites[i].descriptorCount);
4360 }
4361 // further checks only if we have right structtype
4362 if (pnext_struct) {
4363 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4364 skip |= LogError(
4365 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004366 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4367 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004368 ".",
4369 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004370 }
sourav parmarbcee7512020-12-28 14:34:49 -08004371 if (pnext_struct->accelerationStructureCount == 0) {
4372 skip |= LogError(device,
4373 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004374 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004375 }
4376 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004377 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004378 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4379 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4380 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4381 skip |= LogError(device,
4382 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4383 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004384 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004385 }
4386 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004387 }
4388 }
4389 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004390 }
4391 }
4392 return skip;
4393}
4394
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004395bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4396 const VkWriteDescriptorSet *pDescriptorWrites,
4397 uint32_t descriptorCopyCount,
4398 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004399 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004400}
4401
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004402bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004403 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004404 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004405 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4406}
4407
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004408bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4409 const VkAllocationCallbacks *pAllocator,
4410 VkRenderPass *pRenderPass) const {
4411 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4412}
4413
Mike Schuchardt2df08912020-12-15 16:28:09 -08004414bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004415 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004416 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004417 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4418}
4419
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004420bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4421 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004422 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004423 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004424
4425 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4426 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4427 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004428 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4429 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004430 return skip;
4431}
4432
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004433bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004434 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004435 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004436
4437 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4438 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004439 bool cb_is_secondary;
4440 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004441 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004442 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4443 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004444
Tony-LunarG3c287f62020-12-17 12:39:49 -07004445 if (cb_is_secondary) {
4446 // Implicit VUs
4447 // validate only sType here; pointer has to be validated in core_validation
4448 const bool k_not_required = false;
4449 const char *k_no_vuid = nullptr;
4450 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4451 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004452 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4453 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004454
Tony-LunarG3c287f62020-12-17 12:39:49 -07004455 if (info) {
4456 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004457 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004458 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4459 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004460 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004461 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004462 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4463 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4464 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4465 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004466
Tony-LunarG3c287f62020-12-17 12:39:49 -07004467 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004468
Tony-LunarG3c287f62020-12-17 12:39:49 -07004469 // Explicit VUs
4470 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004471 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004472 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4473 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4474 cmd_name);
4475 }
4476
4477 if (physical_device_features.inheritedQueries) {
4478 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004479 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4480 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4481 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004482 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004483 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004484 }
4485
4486 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004487 skip |=
4488 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4489 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4490 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4491 } else { // !pipelineStatisticsQuery
4492 skip |=
4493 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4494 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004495 }
4496
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004497 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004498 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004499 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004500 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4501 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4502 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004503 commandBuffer,
4504 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004505 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4506 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4507 }
Petr Kraus139757b2019-08-15 17:19:33 +02004508 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004509
4510 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4511 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4512 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4513 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4514 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4515 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4516 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4517 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4518 }
Petr Kraus139757b2019-08-15 17:19:33 +02004519 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004520 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004521 return skip;
4522}
4523
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004524bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004525 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004526 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004527
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004528 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004529 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004530 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4531 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4532 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004533 }
4534 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004535 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4536 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4537 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004538 }
4539 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004540 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004541 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004542 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4543 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4544 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4545 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004546 }
4547 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004548
4549 if (pViewports) {
4550 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4551 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004552 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004553 skip |= manual_PreCallValidateViewport(
4554 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004555 }
4556 }
4557
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004558 return skip;
4559}
4560
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004561bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004562 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004563 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004564
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004565 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004566 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004567 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4568 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4569 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004570 }
4571 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004572 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4573 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4574 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004575 }
4576 } else { // multiViewport enabled
4577 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004578 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004579 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4580 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4581 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4582 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004583 }
4584 }
4585
Petr Kraus6260f0a2018-02-27 21:15:55 +01004586 if (pScissors) {
4587 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4588 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004589
Petr Kraus6260f0a2018-02-27 21:15:55 +01004590 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004591 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4592 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4593 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004594 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004595
Petr Kraus6260f0a2018-02-27 21:15:55 +01004596 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004597 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4598 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4599 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004600 }
4601
4602 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4603 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004604 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4605 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4606 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4607 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004608 }
4609
4610 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4611 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004612 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4613 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4614 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4615 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004616 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004617 }
4618 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004619
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004620 return skip;
4621}
4622
Jeff Bolz5c801d12019-10-09 10:38:45 -05004623bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004624 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004625
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004626 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004627 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4628 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004629 }
4630
4631 return skip;
4632}
4633
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004634bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004635 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004636 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004637
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004638 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004639 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004640 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4641 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004642 }
4643 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004644 skip |=
4645 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4646 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4647 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004648 }
4649 return skip;
4650}
4651
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004652bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004653 VkDeviceSize offset, uint32_t drawCount,
4654 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004655 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004656 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004657 skip |=
4658 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4659 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4660 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004661 }
4662 if (drawCount > device_limits.maxDrawIndirectCount) {
4663 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004664 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4665 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004666 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004667 }
4668 return skip;
4669}
4670
sfricke-samsungf692b972020-05-02 08:00:45 -07004671bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4672 VkDeviceSize countBufferOffset, bool khr) const {
4673 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004674 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004675 if (offset & 3) {
4676 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004677 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004678 }
4679
4680 if (countBufferOffset & 3) {
4681 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004682 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004683 countBufferOffset);
4684 }
4685 return skip;
4686}
4687
4688bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4689 VkDeviceSize offset, VkBuffer countBuffer,
4690 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4691 uint32_t stride) const {
4692 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4693}
4694
4695bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4696 VkDeviceSize offset, VkBuffer countBuffer,
4697 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4698 uint32_t stride) const {
4699 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4700}
4701
4702bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4703 VkDeviceSize countBufferOffset, bool khr) const {
4704 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004705 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004706 if (offset & 3) {
4707 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004708 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004709 }
4710
4711 if (countBufferOffset & 3) {
4712 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004713 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004714 countBufferOffset);
4715 }
4716 return skip;
4717}
4718
4719bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4720 VkDeviceSize offset, VkBuffer countBuffer,
4721 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4722 uint32_t stride) const {
4723 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4724}
4725
4726bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4727 VkDeviceSize offset, VkBuffer countBuffer,
4728 VkDeviceSize countBufferOffset,
4729 uint32_t maxDrawCount, uint32_t stride) const {
4730 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4731}
4732
Tony-LunarG4490de42021-06-21 15:49:19 -06004733bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4734 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4735 uint32_t firstInstance, uint32_t stride) const {
4736 bool skip = false;
4737 if (stride & 3) {
4738 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4739 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4740 }
4741 if (drawCount && nullptr == pVertexInfo) {
4742 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4743 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4744 "one or more valid instances of VkMultiDrawInfoEXT structures");
4745 }
4746 return skip;
4747}
4748
4749bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4750 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4751 uint32_t instanceCount, uint32_t firstInstance,
4752 uint32_t stride, const int32_t *pVertexOffset) const {
4753 bool skip = false;
4754 if (stride & 3) {
4755 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4756 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4757 }
4758 if (drawCount && nullptr == pIndexInfo) {
4759 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4760 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4761 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4762 }
4763 return skip;
4764}
4765
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004766bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4767 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004768 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004769 bool skip = false;
4770 for (uint32_t rect = 0; rect < rectCount; rect++) {
4771 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004772 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004773 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004774 }
sfricke-samsung10867682020-04-25 02:20:39 -07004775 if (pRects[rect].rect.extent.width == 0) {
4776 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004777 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004778 }
4779 if (pRects[rect].rect.extent.height == 0) {
4780 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004781 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004782 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004783 }
4784 return skip;
4785}
4786
Andrew Fobel3abeb992020-01-20 16:33:22 -05004787bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4788 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4789 VkImageFormatProperties2 *pImageFormatProperties,
4790 const char *apiName) const {
4791 bool skip = false;
4792
4793 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004794 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004795 if (image_stencil_struct != nullptr) {
4796 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4797 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4798 // No flags other than the legal attachment bits may be set
4799 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4800 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004801 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4802 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4803 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4804 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4805 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004806 }
4807 }
4808 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004809 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4810 if (image_drm_format) {
4811 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4812 skip |= LogError(
4813 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4814 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4815 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4816 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4817 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004818 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4819 skip |= LogError(
4820 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4821 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4822 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4823 apiName, image_drm_format->queueFamilyIndexCount);
4824 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004825 } else {
4826 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4827 skip |= LogError(
4828 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4829 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4830 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4831 apiName);
4832 }
4833 }
4834 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4835 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4836 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4837 if (!format_list || format_list->viewFormatCount == 0) {
4838 skip |= LogError(
4839 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4840 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4841 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4842 apiName);
4843 }
4844 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004845 }
4846
4847 return skip;
4848}
4849
4850bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4851 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4852 VkImageFormatProperties2 *pImageFormatProperties) const {
4853 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4854 "vkGetPhysicalDeviceImageFormatProperties2");
4855}
4856
4857bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4858 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4859 VkImageFormatProperties2 *pImageFormatProperties) const {
4860 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4861 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4862}
4863
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004864bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4865 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4866 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4867 bool skip = false;
4868
4869 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4870 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4871 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4872 }
4873
4874 return skip;
4875}
4876
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004877bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4878 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4879 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4880 bool skip = false;
4881
4882 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4883 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4884 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4885 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4886 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4887 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4888 }
4889
ziga-lunarg42f884b2021-08-25 16:13:20 +02004890 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004891}
4892
sfricke-samsung3999ef62020-02-09 17:05:59 -08004893bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4894 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4895 bool skip = false;
4896
4897 if (pRegions != nullptr) {
4898 for (uint32_t i = 0; i < regionCount; i++) {
4899 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004900 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004901 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004902 }
4903 }
4904 }
4905 return skip;
4906}
4907
Jeff Leger178b1e52020-10-05 12:22:23 -04004908bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4909 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4910 bool skip = false;
4911
4912 if (pCopyBufferInfo->pRegions != nullptr) {
4913 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4914 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06004915 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004916 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004917 }
4918 }
4919 }
4920 return skip;
4921}
4922
Tony-LunarGef035472021-11-02 10:23:33 -06004923bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
4924 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
4925 bool skip = false;
4926
4927 if (pCopyBufferInfo->pRegions != nullptr) {
4928 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4929 if (pCopyBufferInfo->pRegions[i].size == 0) {
4930 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
4931 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
4932 }
4933 }
4934 }
4935 return skip;
4936}
4937
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004938bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004939 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4940 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004941 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004942
4943 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004944 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4945 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4946 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004947 }
4948
4949 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004950 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4951 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4952 "), must be greater than zero and less than or equal to 65536.",
4953 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004954 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004955 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4956 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4957 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004958 }
4959 return skip;
4960}
4961
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004962bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004963 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004964 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004965
4966 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004967 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4968 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4969 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004970 }
4971
4972 if (size != VK_WHOLE_SIZE) {
4973 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004974 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004975 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4976 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004977 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004978 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4979 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004980 }
4981 }
4982 return skip;
4983}
4984
sfricke-samsunga1d00272021-03-10 21:37:41 -08004985bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004986 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004987
4988 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004989 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4990 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4991 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4992 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004993 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004994 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4995 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4996 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004997 }
4998
4999 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
5000 // queueFamilyIndexCount uint32_t values
5001 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005002 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005003 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005004 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08005005 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
5006 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005007 }
5008 }
5009
Dave Houlton413a6782018-05-22 13:01:54 -06005010 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005011 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005012
sfricke-samsunga1d00272021-03-10 21:37:41 -08005013 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
5014 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
5015 if (format_list_info) {
5016 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
5017 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
5018 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
5019 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005020 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
5021 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005022 func_name, viewFormatCount);
5023 }
5024
5025 // Using the first format, compare the rest of the formats against it that they are compatible
5026 for (uint32_t i = 1; i < viewFormatCount; i++) {
5027 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
5028 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
5029 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
5030 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005031 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
5032 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005033 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
5034 string_VkFormat(format_list_info->pViewFormats[i]));
5035 }
5036 }
5037 }
5038
5039 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
5040 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
5041 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
5042 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
5043 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
5044 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
5045 func_name);
5046 } else {
5047 if (format_list_info == nullptr) {
5048 skip |= LogError(
5049 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5050 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
5051 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
5052 func_name);
5053 } else if (format_list_info->viewFormatCount == 0) {
5054 skip |= LogError(
5055 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5056 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
5057 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
5058 func_name);
5059 } else {
5060 bool found_base_format = false;
5061 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5062 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5063 found_base_format = true;
5064 break;
5065 }
5066 }
5067 if (!found_base_format) {
5068 skip |=
5069 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5070 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5071 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5072 "pCreateInfo->imageFormat.",
5073 func_name);
5074 }
5075 }
5076 }
5077 }
5078 }
5079 return skip;
5080}
5081
5082bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5083 const VkAllocationCallbacks *pAllocator,
5084 VkSwapchainKHR *pSwapchain) const {
5085 bool skip = false;
5086 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5087 return skip;
5088}
5089
5090bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5091 const VkSwapchainCreateInfoKHR *pCreateInfos,
5092 const VkAllocationCallbacks *pAllocator,
5093 VkSwapchainKHR *pSwapchains) const {
5094 bool skip = false;
5095 if (pCreateInfos) {
5096 for (uint32_t i = 0; i < swapchainCount; i++) {
5097 std::stringstream func_name;
5098 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5099 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5100 }
5101 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005102 return skip;
5103}
5104
Jeff Bolz5c801d12019-10-09 10:38:45 -05005105bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005106 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005107
5108 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005109 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005110 if (present_regions) {
5111 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005112 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005113 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5114 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005115 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005116 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5117 "extension swapchainCount is %i. These values must be equal.",
5118 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005119 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005120 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005121 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5122 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005123 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5124 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5125 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005126 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005127 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005128 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005129 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005130 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005131 }
5132 }
5133
5134 return skip;
5135}
5136
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005137bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5138 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5139 const VkAllocationCallbacks *pAllocator,
5140 VkDisplayModeKHR *pMode) const {
5141 bool skip = false;
5142
5143 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5144 if (display_mode_parameters.visibleRegion.width == 0) {
5145 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5146 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5147 }
5148 if (display_mode_parameters.visibleRegion.height == 0) {
5149 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5150 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5151 }
5152 if (display_mode_parameters.refreshRate == 0) {
5153 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5154 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5155 }
5156
5157 return skip;
5158}
5159
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005160#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005161bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5162 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5163 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005164 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005165 bool skip = false;
5166
5167 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005168 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5169 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005170 }
5171
5172 return skip;
5173}
5174#endif // VK_USE_PLATFORM_WIN32_KHR
5175
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005176static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5177 bool partial_overlap = false;
5178
5179 static const std::vector<VkDescriptorType> all_descriptor_types = {
5180 VK_DESCRIPTOR_TYPE_SAMPLER,
5181 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5182 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5183 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5184 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5185 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5186 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5187 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5188 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5189 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5190 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5191 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5192 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5193 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5194 };
5195
5196 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5197 if (mutable_descriptor_type) {
5198 std::vector<VkDescriptorType> first_types, second_types;
5199 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5200 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5201 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5202 }
5203 } else {
5204 first_types = all_descriptor_types;
5205 }
5206 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5207 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5208 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5209 }
5210 } else {
5211 second_types = all_descriptor_types;
5212 }
5213
5214 bool complete_overlap = first_types.size() == second_types.size();
5215 bool disjoint = true;
5216 for (const auto first_type : first_types) {
5217 bool found = false;
5218 for (const auto second_type : second_types) {
5219 if (first_type == second_type) {
5220 found = true;
5221 break;
5222 }
5223 }
5224 if (found) {
5225 disjoint = false;
5226 } else {
5227 complete_overlap = false;
5228 }
5229 if (!disjoint && !complete_overlap) {
5230 partial_overlap = true;
5231 break;
5232 }
5233 }
5234 }
5235
5236 return partial_overlap;
5237}
5238
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005239bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005240 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005241 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005242 bool skip = false;
5243
5244 if (pCreateInfo) {
5245 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005246 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5247 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005248 }
5249
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005250 const auto *mutable_descriptor_type_features =
5251 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5252 bool mutable_descriptor_type_enabled =
5253 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5254
Petr Krausc8655be2017-09-27 18:56:51 +02005255 if (pCreateInfo->pPoolSizes) {
5256 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5257 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005258 skip |= LogError(
5259 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005260 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005261 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005262 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5263 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005264 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5265 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5266 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5267 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5268 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005269 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005270 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5271 skip |=
5272 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5273 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5274 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5275 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5276 i);
5277 }
5278 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5279 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5280 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5281 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5282 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5283 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5284 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5285 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5286 " and have sets which partially overlap.",
5287 i, j);
5288 }
5289 }
5290 }
5291 }
Petr Krausc8655be2017-09-27 18:56:51 +02005292 }
5293 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005294
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005295 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5296 skip |=
5297 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5298 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5299 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5300 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005301 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5302 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5303 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5304 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5305 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5306 }
Petr Krausc8655be2017-09-27 18:56:51 +02005307 }
5308
5309 return skip;
5310}
5311
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005312bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005313 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005314 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005315
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005316 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005317 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005318 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5319 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5320 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005321 }
5322
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005323 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005324 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005325 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5326 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5327 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005328 }
5329
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005330 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005331 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005332 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5333 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5334 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005335 }
5336
5337 return skip;
5338}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005339
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005340bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005341 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005342 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005343
5344 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005345 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5346 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005347 }
5348 return skip;
5349}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005350
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005351bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5352 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005353 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005354 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005355
5356 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005357 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005358 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005359 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5360 "vkCmdDispatch(): baseGroupX (%" PRIu32
5361 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5362 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005363 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005364 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5365 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5366 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5367 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005368 }
5369
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005370 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005371 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005372 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5373 "vkCmdDispatch(): baseGroupY (%" PRIu32
5374 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5375 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005376 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005377 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5378 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5379 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5380 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005381 }
5382
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005383 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005384 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005385 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5386 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5387 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5388 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005389 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005390 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5391 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5392 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5393 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005394 }
5395
5396 return skip;
5397}
5398
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005399bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5400 VkPipelineBindPoint pipelineBindPoint,
5401 VkPipelineLayout layout, uint32_t set,
5402 uint32_t descriptorWriteCount,
5403 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005404 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005405}
5406
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005407bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5408 uint32_t firstExclusiveScissor,
5409 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005410 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005411 bool skip = false;
5412
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005413 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005414 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005415 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005416 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5417 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5418 ") is not 0.",
5419 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005420 }
5421 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005422 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005423 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5424 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5425 ") is not 1.",
5426 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005427 }
5428 } else { // multiViewport enabled
5429 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005430 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005431 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5432 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5433 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5434 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005435 }
5436 }
5437
Jeff Bolz3e71f782018-08-29 23:15:45 -05005438 if (pExclusiveScissors) {
5439 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5440 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5441
5442 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005443 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5444 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5445 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005446 }
5447
5448 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005449 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5450 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5451 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005452 }
5453
5454 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5455 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005456 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5457 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5458 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5459 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005460 }
5461
5462 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5463 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005464 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5465 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5466 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5467 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005468 }
5469 }
5470 }
5471
5472 return skip;
5473}
5474
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005475bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5476 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005477 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005478 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005479 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5480 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5481 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5482 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5483 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5484 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005485 }
5486
5487 return skip;
5488}
5489
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005490bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5491 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005492 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005493 bool skip = false;
5494
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005495 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005496 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005497 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005498 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5499 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5500 ") is not 0.",
5501 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005502 }
5503 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005504 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005505 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5506 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5507 ") is not 1.",
5508 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005509 }
5510 }
5511
Jeff Bolz9af91c52018-09-01 21:53:57 -05005512 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005513 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005514 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5515 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5516 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5517 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005518 }
5519
5520 return skip;
5521}
5522
Jeff Bolz5c801d12019-10-09 10:38:45 -05005523bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5524 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5525 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005526 bool skip = false;
5527
Dave Houlton142c4cb2018-10-17 15:04:41 -06005528 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005529 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5530 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5531 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005532 }
5533
5534 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005535 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005536 }
5537
5538 return skip;
5539}
5540
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005541bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005542 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005543 bool skip = false;
5544
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005545 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005546 skip |= LogError(
5547 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005548 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5549 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005550 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005551 }
5552
5553 return skip;
5554}
5555
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005556bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5557 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005558 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005559 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005560 static const int condition_multiples = 0b0011;
5561 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005562 skip |= LogError(
5563 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005564 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005565 }
Lockee1c22882019-06-10 16:02:54 -06005566 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005567 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5568 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5569 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5570 stride);
Lockee1c22882019-06-10 16:02:54 -06005571 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005572 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005573 skip |= LogError(
5574 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005575 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5576 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005577 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005578 if (drawCount > device_limits.maxDrawIndirectCount) {
5579 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005580 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5581 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005582 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005583 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005584 return skip;
5585}
5586
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005587bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5588 VkDeviceSize offset, VkBuffer countBuffer,
5589 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005590 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005591 bool skip = false;
5592
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005593 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005594 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5595 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5596 "), is not a multiple of 4.",
5597 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005598 }
5599
5600 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005601 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5602 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5603 "), is not a multiple of 4.",
5604 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005605 }
5606
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005607 return skip;
5608}
5609
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005610bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005611 const VkAllocationCallbacks *pAllocator,
5612 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005613 bool skip = false;
5614
5615 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5616 if (pCreateInfo != nullptr) {
5617 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5618 // VkQueryPipelineStatisticFlagBits values
5619 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5620 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005621 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5622 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5623 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5624 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005625 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005626 if (pCreateInfo->queryCount == 0) {
5627 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5628 "vkCreateQueryPool(): queryCount must be greater than zero.");
5629 }
ziga-lunarg1052d492022-04-03 20:12:15 +02005630 if (pCreateInfo->queryType == VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT) {
5631 const auto *primitives_generated_query_features =
5632 LvlFindInChain<VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT>(device_createinfo_pnext);
5633 if (!primitives_generated_query_features || primitives_generated_query_features->primitivesGeneratedQuery == VK_FALSE) {
5634 skip |= LogError(device, "VUID-vkCmdBeginQuery-queryType-06688",
5635 "vkCreateQueryPool(): If pCreateInfo->queryType is VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT primitivesGeneratedQuery feature must be enabled.");
5636 }
5637 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005638 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005639 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005640}
5641
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005642bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5643 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005644 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005645 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5646 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005647}
5648
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005649void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005650 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5651 VkResult result) {
5652 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005653 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005654}
5655
Mike Schuchardt2df08912020-12-15 16:28:09 -08005656void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005657 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5658 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005659 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005660 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005661 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005662}
5663
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005664void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5665 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005666 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005667 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005668 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005669}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005670
Tony-LunarG3c287f62020-12-17 12:39:49 -07005671void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005672 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005673 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005674 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005675 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005676 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005677 }
5678 }
5679}
5680
5681void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005682 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005683 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005684 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5685 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5686 }
5687}
5688
5689void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005690 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005691 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005692 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5693 if (item->second == commandPool) {
5694 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005695 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005696 ++item;
5697 }
5698 }
5699}
5700
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005701bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005702 const VkAllocationCallbacks *pAllocator,
5703 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005704 bool skip = false;
5705
5706 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005707 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005708 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005709 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5710 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005711 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005712
5713 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005714 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005715 if (flags_info) {
5716 flags = flags_info->flags;
5717 }
5718
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005719 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005720 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005721 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005722 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5723 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005724 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005725 }
5726
5727#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005728 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005729#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005730 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5731 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005732#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005733 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005734#endif
5735
5736 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005737 skip |= LogError(
5738 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005739 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5740 }
5741 if (
5742#ifdef VK_USE_PLATFORM_WIN32_KHR
5743 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5744#endif
5745 (import_memory_fd && import_memory_fd->handleType) ||
5746#ifdef VK_USE_PLATFORM_ANDROID_KHR
5747 (import_memory_ahb && import_memory_ahb->buffer) ||
5748#endif
5749 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005750 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5751 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005752 }
5753 }
5754
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005755 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5756 if (export_memory) {
5757 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5758 if (export_memory_nv) {
5759 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5760 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5761 "VkExportMemoryAllocateInfoNV");
5762 }
5763#ifdef VK_USE_PLATFORM_WIN32_KHR
5764 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5765 if (export_memory_win32_nv) {
5766 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5767 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5768 "VkExportMemoryWin32HandleInfoNV");
5769 }
5770#endif
5771 }
5772
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005773 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005774 VkBool32 capture_replay = false;
5775 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005776 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005777 if (vulkan_12_features) {
5778 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5779 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5780 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005781 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005782 if (bda_features) {
5783 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5784 buffer_device_address = bda_features->bufferDeviceAddress;
5785 }
5786 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005787 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005788 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005789 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005790 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005791 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005792 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005793 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005794 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005795 }
5796 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005797 }
5798 return skip;
5799}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005800
Jason Macnak192fa0e2019-07-26 15:07:16 -07005801bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005802 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005803 bool skip = false;
5804
5805 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5806 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5807 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005808 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005809 } else {
5810 uint32_t vertex_component_size = 0;
5811 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5812 vertex_component_size = 4;
5813 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5814 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5815 vertex_component_size = 2;
5816 }
5817 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005818 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005819 }
5820 }
5821
5822 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5823 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005824 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005825 } else {
5826 uint32_t index_element_size = 0;
5827 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5828 index_element_size = 4;
5829 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5830 index_element_size = 2;
5831 }
5832 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005833 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005834 }
5835 }
5836 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5837 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005838 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005839 }
5840 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005841 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005842 }
5843 }
5844
5845 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005846 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005847 }
5848
5849 return skip;
5850}
5851
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005852bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5853 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005854 bool skip = false;
5855
5856 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005857 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005858 }
5859 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005860 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005861 }
5862
5863 return skip;
5864}
5865
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005866bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5867 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005868 bool skip = false;
5869 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005870 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005871 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005872 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005873 }
5874 return skip;
5875}
5876
5877bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005878 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005879 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005880 bool skip = false;
5881 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005882 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5883 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5884 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005885 }
5886 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005887 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5888 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5889 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005890 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005891 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5892 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5893 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5894 }
Jason Macnak5c954952019-07-09 15:46:12 -07005895 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5896 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005897 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5898 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5899 "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 -07005900 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005901 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005902 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005903 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5904 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005905 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5906 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005907 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005908 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005909 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5910 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5911 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005912 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005913 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005914 uint64_t total_triangle_count = 0;
5915 for (uint32_t i = 0; i < info.geometryCount; i++) {
5916 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005917
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005918 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005919
Jason Macnak5c954952019-07-09 15:46:12 -07005920 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5921 continue;
5922 }
5923 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5924 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005925 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005926 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5927 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5928 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005929 }
5930 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005931 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5932 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5933 for (uint32_t i = 1; i < info.geometryCount; i++) {
5934 const VkGeometryNV &geometry = info.pGeometries[i];
5935 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005936 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005937 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5938 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005939 "info.pGeometries[0].geometryType.",
5940 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005941 }
5942 }
5943 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005944 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5945 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5946 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5947 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5948 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5949 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5950 }
5951 }
5952 skip |=
5953 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005954 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005955 return skip;
5956}
5957
Ricardo Garciaa4935972019-02-21 17:43:18 +01005958bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5959 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005960 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005961 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005962 if (pCreateInfo) {
5963 if ((pCreateInfo->compactedSize != 0) &&
5964 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005965 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5966 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5967 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5968 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005969 }
Jason Macnak5c954952019-07-09 15:46:12 -07005970
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005971 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005972 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005973 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005974 return skip;
5975}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005976
Jeff Bolz5c801d12019-10-09 10:38:45 -05005977bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5978 const VkAccelerationStructureInfoNV *pInfo,
5979 VkBuffer instanceData, VkDeviceSize instanceOffset,
5980 VkBool32 update, VkAccelerationStructureNV dst,
5981 VkAccelerationStructureNV src, VkBuffer scratch,
5982 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005983 bool skip = false;
5984
5985 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005986 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005987 }
5988
5989 return skip;
5990}
5991
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005992bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5993 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5994 VkAccelerationStructureKHR *pAccelerationStructure) const {
5995 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005996 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005997 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005998 if (!acceleration_structure_features ||
5999 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
6000 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
6001 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
6002 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006003 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006004 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
6005 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006006 (acceleration_structure_features &&
6007 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006008 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07006009 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
6010 "vkCreateAccelerationStructureKHR(): If createFlags includes "
6011 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
6012 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07006013 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006014 if (pCreateInfo->deviceAddress &&
6015 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
6016 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
6017 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
6018 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
6019 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006020 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
6021 (acceleration_structure_features &&
6022 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
6023 skip |= LogError(
6024 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
6025 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
6026 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
6027 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006028 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
6029 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006030 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
6031 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07006032 }
sourav parmar83c31b12020-05-06 12:30:54 -07006033 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006034 return skip;
6035}
6036
Jason Macnak5c954952019-07-09 15:46:12 -07006037bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
6038 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006039 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006040 bool skip = false;
6041 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006042 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
6043 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07006044 }
6045 return skip;
6046}
6047
sourav parmarcd5fb182020-07-17 12:58:44 -07006048bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
6049 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
6050 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6051 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006052 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07006053 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07006054 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006055 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006056 }
6057 return skip;
6058}
6059
Peter Chen85366392019-05-14 15:20:11 -04006060bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6061 uint32_t createInfoCount,
6062 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6063 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006064 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006065 bool skip = false;
6066
6067 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006068 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6069 std::stringstream msg;
6070 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6071 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6072 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006073 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006074 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Tony-LunarGce3244a2021-11-19 12:33:40 -07006075 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006076 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6077 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6078 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6079 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006080 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006081
6082 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006083 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006084 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6085 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6086 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6087 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6088 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6089 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6090 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6091 }
6092 }
6093
sourav parmarf4a78252020-04-10 13:04:21 -07006094 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6095 skip |=
6096 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6097 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6098 }
6099 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6100 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6101 skip |=
6102 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6103 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6104 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6105 }
6106 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6107 if (pCreateInfos[i].basePipelineIndex != -1) {
6108 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6109 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6110 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6111 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6112 "and pCreateInfos->basePipelineIndex is not -1.");
6113 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006114 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006115 skip |=
6116 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6117 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6118 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6119 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6120 "that element.");
6121 }
sourav parmarf4a78252020-04-10 13:04:21 -07006122 }
6123 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006124 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006125 skip |=
6126 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6127 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6128 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6129 "commands pCreateInfos parameter.");
6130 }
6131 } else {
6132 if (pCreateInfos[i].basePipelineIndex != -1) {
6133 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6134 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6135 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6136 }
6137 }
6138 }
6139 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6140 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6141 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6142 }
6143 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6144 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6145 "vkCreateRayTracingPipelinesNV: flags must not include "
6146 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6147 }
6148 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6149 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6150 "vkCreateRayTracingPipelinesNV: flags must not include "
6151 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6152 }
6153 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6154 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6155 "vkCreateRayTracingPipelinesNV: flags must not include "
6156 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6157 }
6158 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6159 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6160 "vkCreateRayTracingPipelinesNV: flags must not include "
6161 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6162 }
6163 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6164 skip |= LogError(
6165 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6166 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6167 }
6168 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6169 skip |= LogError(
6170 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6171 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6172 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006173 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6174 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6175 "vkCreateRayTracingPipelinesNV: flags must not include "
6176 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6177 }
6178 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6179 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6180 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6181 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006182 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6183 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6184 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6185 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6186 }
Peter Chen85366392019-05-14 15:20:11 -04006187 }
6188
6189 return skip;
6190}
6191
sourav parmarcd5fb182020-07-17 12:58:44 -07006192bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6193 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6194 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006195 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006196 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006197 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6198 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6199 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006200 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006201 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006202 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6203 std::stringstream msg;
6204 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6205 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006206 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006207 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006208 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6209 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6210 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6211 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6212 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6213 }
6214 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6215 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6216 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6217 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6218 }
6219 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006220 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006221 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Tony-LunarGce3244a2021-11-19 12:33:40 -07006222 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfo-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07006223 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6224 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6225 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006226 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6227 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6228 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006229 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006230 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006231 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6232 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6233 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6234 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006235 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006236 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6237 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6238 }
6239 }
sourav parmarf4a78252020-04-10 13:04:21 -07006240 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006241 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6242 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006243 }
6244 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006245 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006246 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006247 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6248 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006249 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006250 }
6251 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6252 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6253 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006254 }
6255 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6256 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6257 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6258 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6259 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6260 skip |= LogError(
6261 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006262 "vkCreateRayTracingPipelinesKHR: If flags includes "
6263 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006264 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6265 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6266 "must not be VK_SHADER_UNUSED_KHR");
6267 }
6268 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6269 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6270 skip |= LogError(
6271 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006272 "vkCreateRayTracingPipelinesKHR: If flags includes "
6273 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006274 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6275 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6276 "element must not be VK_SHADER_UNUSED_KHR");
6277 }
6278 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006279 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6280 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6281 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6282 skip |= LogError(
6283 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6284 "vkCreateRayTracingPipelinesKHR: If "
6285 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6286 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6287 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6288 }
6289 }
sourav parmarf4a78252020-04-10 13:04:21 -07006290 }
6291 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6292 if (pCreateInfos[i].basePipelineIndex != -1) {
6293 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6294 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006295 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006296 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6297 "and pCreateInfos->basePipelineIndex is not -1.");
6298 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006299 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006300 skip |=
6301 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6302 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6303 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6304 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6305 "element.");
6306 }
sourav parmarf4a78252020-04-10 13:04:21 -07006307 }
6308 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006309 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006310 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006311 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006312 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6313 ") must be a valid into the calling"
6314 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006315 pCreateInfos[i].basePipelineIndex, createInfoCount);
6316 }
6317 } else {
6318 if (pCreateInfos[i].basePipelineIndex != -1) {
6319 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006320 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006321 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6322 }
6323 }
6324 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006325 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6326 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6327 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6328 "vkCreateRayTracingPipelinesKHR: If flags includes "
6329 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6330 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006331 }
6332 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6333 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6334 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6335 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6336 "pLibraryInfo and pLibraryInterface must be NULL.");
6337 }
6338 if (pCreateInfos[i].pLibraryInfo) {
6339 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6340 if (pCreateInfos[i].stageCount == 0) {
6341 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6342 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6343 "stageCount must not be 0.");
6344 }
6345 if (pCreateInfos[i].groupCount == 0) {
6346 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6347 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6348 "groupCount must not be 0.");
6349 }
6350 } else {
6351 if (pCreateInfos[i].pLibraryInterface == NULL) {
6352 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6353 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6354 "is greater than 0, its "
6355 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006356 }
6357 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006358 }
6359 if (pCreateInfos[i].pLibraryInterface) {
6360 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6361 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6362 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6363 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6364 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6365 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006366 }
6367 if (deferredOperation != VK_NULL_HANDLE) {
6368 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6369 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6370 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6371 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006372 }
6373 }
ziga-lunargdea76582021-09-17 14:38:08 +02006374 if (pCreateInfos[i].pDynamicState) {
6375 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6376 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6377 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6378 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6379 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6380 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6381 }
6382 }
6383 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006384 }
6385
6386 return skip;
6387}
6388
Mike Schuchardt21638df2019-03-16 10:52:02 -07006389#ifdef VK_USE_PLATFORM_WIN32_KHR
6390bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6391 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006392 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006393 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006394 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006395 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006396 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006397 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006398 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006399 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006400 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006401 skip |=
6402 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006403 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006404 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6405 skip |= validate_struct_type(
6406 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6407 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6408 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6409 if (pSurfaceInfo != NULL) {
6410 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6411 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6412 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6413
6414 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6415 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6416 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6417 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006418 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6419 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006420
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006421 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6422 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6423 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6424 "VK_GOOGLE_surfaceless_query is not enabled.");
6425 }
6426
Mike Schuchardt21638df2019-03-16 10:52:02 -07006427 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6428 }
6429 return skip;
6430}
6431#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006432
6433bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6434 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006435 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006436 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6437 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006438 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006439 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6440 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6441 }
6442 return skip;
6443}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006444
6445bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006446 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006447 bool skip = false;
6448
6449 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006450 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006451 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006452 }
6453
6454 return skip;
6455}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006456
6457bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006458 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006459 bool skip = false;
6460
6461 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006462 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6463 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006464 }
6465
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006466 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006467 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006468 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6469 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006470 }
6471
6472 return skip;
6473}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006474
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006475bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6476 uint32_t bindingCount, const VkBuffer *pBuffers,
6477 const VkDeviceSize *pOffsets) const {
6478 bool skip = false;
6479 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006480 skip |=
6481 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6482 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6483 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006484 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6485 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006486 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6487 ") must be less than "
6488 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006489 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6490 }
6491
Jeff Bolz165818a2020-05-08 11:19:03 -05006492 for (uint32_t i = 0; i < bindingCount; ++i) {
6493 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006494 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006495 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006496 skip |=
6497 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6498 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006499 } else {
6500 if (pOffsets[i] != 0) {
6501 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006502 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6503 "] is not 0",
6504 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006505 }
6506 }
6507 }
6508 }
6509
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006510 return skip;
6511}
6512
Mark Lobodzinski84988402019-09-11 15:27:30 -06006513bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006514 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006515 bool skip = false;
6516 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006517 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6518 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006519 }
6520 return skip;
6521}
6522
6523bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006524 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006525 bool skip = false;
6526 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006527 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6528 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006529 }
6530 return skip;
6531}
Petr Kraus3d720392019-11-13 02:52:39 +01006532
6533bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6534 VkSemaphore semaphore, VkFence fence,
6535 uint32_t *pImageIndex) const {
6536 bool skip = false;
6537
6538 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006539 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6540 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006541 }
6542
6543 return skip;
6544}
6545
6546bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6547 uint32_t *pImageIndex) const {
6548 bool skip = false;
6549
6550 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006551 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6552 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006553 }
6554
6555 return skip;
6556}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006557
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006558bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6559 uint32_t firstBinding, uint32_t bindingCount,
6560 const VkBuffer *pBuffers,
6561 const VkDeviceSize *pOffsets,
6562 const VkDeviceSize *pSizes) const {
6563 bool skip = false;
6564
6565 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6566 for (uint32_t i = 0; i < bindingCount; ++i) {
6567 if (pOffsets[i] & 3) {
6568 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6569 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6570 }
6571 }
6572
6573 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6574 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6575 "%s: The firstBinding(%" PRIu32
6576 ") index is greater than or equal to "
6577 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6578 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6579 }
6580
6581 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6582 skip |=
6583 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6584 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6585 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6586 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6587 }
6588
6589 for (uint32_t i = 0; i < bindingCount; ++i) {
6590 // pSizes is optional and may be nullptr.
6591 if (pSizes != nullptr) {
6592 if (pSizes[i] != VK_WHOLE_SIZE &&
6593 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6594 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6595 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6596 ") is not VK_WHOLE_SIZE and is greater than "
6597 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6598 cmd_name, i, pSizes[i]);
6599 }
6600 }
6601 }
6602
6603 return skip;
6604}
6605
6606bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6607 uint32_t firstCounterBuffer,
6608 uint32_t counterBufferCount,
6609 const VkBuffer *pCounterBuffers,
6610 const VkDeviceSize *pCounterBufferOffsets) const {
6611 bool skip = false;
6612
6613 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6614 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6615 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6616 "%s: The firstCounterBuffer(%" PRIu32
6617 ") index is greater than or equal to "
6618 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6619 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6620 }
6621
6622 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6623 skip |=
6624 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6625 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6626 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6627 cmd_name, firstCounterBuffer, counterBufferCount,
6628 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6629 }
6630
6631 return skip;
6632}
6633
6634bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6635 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6636 const VkBuffer *pCounterBuffers,
6637 const VkDeviceSize *pCounterBufferOffsets) const {
6638 bool skip = false;
6639
6640 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6641 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6642 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6643 "%s: The firstCounterBuffer(%" PRIu32
6644 ") index is greater than or equal to "
6645 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6646 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6647 }
6648
6649 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6650 skip |=
6651 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6652 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6653 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6654 cmd_name, firstCounterBuffer, counterBufferCount,
6655 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6656 }
6657
6658 return skip;
6659}
6660
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006661bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6662 uint32_t firstInstance, VkBuffer counterBuffer,
6663 VkDeviceSize counterBufferOffset,
6664 uint32_t counterOffset, uint32_t vertexStride) const {
6665 bool skip = false;
6666
6667 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006668 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6669 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6670 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6671 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006672 }
6673
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006674 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006675 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006676 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006677 }
6678
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006679 return skip;
6680}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006681
6682bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6683 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6684 const VkAllocationCallbacks *pAllocator,
6685 VkSamplerYcbcrConversion *pYcbcrConversion,
6686 const char *apiName) const {
6687 bool skip = false;
6688
6689 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006690 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006691 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006692 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006693 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6694 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006695 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006696 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006697 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006698
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006699#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006700 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006701 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006702#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006703 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006704#endif
6705
sfricke-samsung1a72f942020-07-25 12:09:18 -07006706 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006707
6708 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006709 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006710 const VkComponentMapping components = pCreateInfo->components;
6711 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6712 if (FormatIsXChromaSubsampled(format) == true) {
6713 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6714 skip |=
6715 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006716 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6717 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006718 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006719 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006720
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006721 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6722 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6723 skip |= LogError(
6724 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6725 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6726 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6727 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6728 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006729
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006730 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6731 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6732 skip |=
6733 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006734 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6735 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006736 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006737 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006738
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006739 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6740 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6741 skip |=
6742 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006743 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6744 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006745 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006746 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006747
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006748 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006749 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6750 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6751 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006752 skip |=
6753 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006754 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6755 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006756 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6757 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006758 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006759 }
6760
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006761 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6762 // Checks same VU multiple ways in order to give a more useful error message
6763 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6764 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6765 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6766 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6767 skip |= LogError(
6768 device, vuid,
6769 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6770 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6771 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6772 string_VkComponentSwizzle(components.b));
6773 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006774
sfricke-samsunged028b02021-09-06 23:14:51 -07006775 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6776 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006777 // 3 = no [a]
6778 // 2 = no [b,a]
6779 // 1 = no [g,b,a]
6780 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006781 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006782
sfricke-samsunged028b02021-09-06 23:14:51 -07006783 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6784 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006785 skip |= LogError(device, vuid,
6786 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6787 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6788 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6789 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006790 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006791 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6792 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6793 skip |= LogError(device, vuid,
6794 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6795 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6796 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6797 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6798 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006799 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006800 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6801 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6802 skip |= LogError(device, vuid,
6803 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6804 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6805 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6806 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6807 string_VkComponentSwizzle(components.b));
6808 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006809 }
6810 }
6811
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006812 return skip;
6813}
6814
6815bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6816 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6817 const VkAllocationCallbacks *pAllocator,
6818 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6819 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6820 "vkCreateSamplerYcbcrConversion");
6821}
6822
6823bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6824 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6825 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6826 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6827 "vkCreateSamplerYcbcrConversionKHR");
6828}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006829
6830bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6831 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6832 bool skip = false;
6833 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6834 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6835
6836 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006837 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6838 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6839 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6840 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6841 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006842 }
6843 return skip;
6844}
sourav parmara96ab1a2020-04-25 16:28:23 -07006845
6846bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006847 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006848 bool skip = false;
6849 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6850 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6851 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6852 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006853 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006854 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6855 skip |= LogError(
6856 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6857 "vkCopyAccelerationStructureToMemoryKHR: The "
6858 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6859 }
6860 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6861 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6862 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6863 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6864 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6865 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006866 return skip;
6867}
6868
6869bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6870 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6871 bool skip = false;
6872 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6873 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6874 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6875 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6876 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006877 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6878 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006879 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006880 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006881 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006882 return skip;
6883}
6884
6885bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6886 const char *api_name) const {
6887 bool skip = false;
6888 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6889 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6890 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6891 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6892 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6893 api_name);
6894 }
6895 return skip;
6896}
6897
6898bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006899 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006900 bool skip = false;
6901 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006902 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006903 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006904 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006905 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6906 "vkCopyAccelerationStructureKHR: The "
6907 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006908 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006909 return skip;
6910}
6911
6912bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6913 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6914 bool skip = false;
6915 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6916 return skip;
6917}
6918
6919bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006920 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006921 bool skip = false;
6922 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006923 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006924 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6925 }
6926 return skip;
6927}
6928
6929bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006930 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006931 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006932 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006933 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006934 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6935 skip |= LogError(
6936 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6937 "vkCopyMemoryToAccelerationStructureKHR: The "
6938 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006939 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006940 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6941 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006942 return skip;
6943}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006944
sourav parmara96ab1a2020-04-25 16:28:23 -07006945bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6946 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6947 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006948 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006949 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6950 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006951 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006952 pInfo->src.deviceAddress);
6953 }
sourav parmar83c31b12020-05-06 12:30:54 -07006954 return skip;
6955}
6956bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6957 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6958 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6959 bool skip = false;
6960 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6961 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6962 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6963 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6964 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6965 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6966 }
6967 return skip;
6968}
6969bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6970 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6971 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6972 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006973 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006974 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6975 skip |= LogError(
6976 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6977 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6978 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6979 }
sourav parmar83c31b12020-05-06 12:30:54 -07006980 if (dataSize < accelerationStructureCount * stride) {
6981 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6982 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006983 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006984 dataSize, accelerationStructureCount, stride);
6985 }
6986 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6987 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6988 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6989 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6990 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6991 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6992 }
6993 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6994 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6995 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6996 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6997 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6998 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6999 stride);
7000 }
7001 }
7002 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
7003 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7004 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
7005 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7006 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
7007 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7008 stride);
7009 }
7010 }
sourav parmar83c31b12020-05-06 12:30:54 -07007011 return skip;
7012}
7013bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
7014 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
7015 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007016 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007017 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
7018 skip |= LogError(
7019 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
7020 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
7021 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07007022 }
7023 return skip;
7024}
7025
7026bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07007027 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7028 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
7029 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7030 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07007031 uint32_t width, uint32_t height, uint32_t depth) const {
7032 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07007033 // RayGen
7034 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7035 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
7036 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007037 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007038 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7039 0) {
7040 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
7041 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7042 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7043 }
7044 // Callable
7045 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7046 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
7047 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7048 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007049 }
7050 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7051 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
7052 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007053 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7054 }
7055 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7056 0) {
7057 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
7058 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7059 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007060 }
7061 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007062 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7063 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7064 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7065 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007066 }
7067 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7068 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007069 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7070 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007071 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007072 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7073 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7074 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7075 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7076 }
sourav parmar83c31b12020-05-06 12:30:54 -07007077 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007078 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7079 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7080 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7081 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007082 }
7083 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7084 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7085 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007086 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7087 }
7088 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7089 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7090 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7091 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7092 }
7093 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
7094 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
7095 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7096 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7097 }
7098 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7099 skip |=
7100 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
7101 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7102 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007103 }
7104
sourav parmarcd5fb182020-07-17 12:58:44 -07007105 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7106 skip |=
7107 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
7108 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7109 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7110 }
7111
7112 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7113 skip |=
7114 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
7115 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7116 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007117 }
7118 return skip;
7119}
7120
sourav parmarcd5fb182020-07-17 12:58:44 -07007121bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7122 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7123 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7124 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007125 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007126 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007127 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7128 skip |= LogError(
7129 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7130 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7131 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007132 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007133 // RayGen
7134 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7135 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7136 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007137 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007138 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7139 0) {
7140 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7141 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7142 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7143 }
7144 // Callabe
7145 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7146 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7147 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7148 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007149 }
7150 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7151 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007152 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7153 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7154 }
7155 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7156 0) {
7157 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7158 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7159 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007160 }
7161 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007162 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7163 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7164 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7165 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007166 }
7167 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7168 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007169 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7170 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007171 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007172 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7173 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7174 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7175 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7176 }
sourav parmar83c31b12020-05-06 12:30:54 -07007177 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007178 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7179 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7180 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7181 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007182 }
7183 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7184 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007185 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7186 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7187 }
7188 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7189 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7190 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7191 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007192 }
7193
sourav parmarcd5fb182020-07-17 12:58:44 -07007194 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7195 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7196 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007197 }
7198 return skip;
7199}
7200bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7201 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7202 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7203 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7204 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7205 uint32_t width, uint32_t height, uint32_t depth) const {
7206 bool skip = false;
7207 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7208 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7209 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7210 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7211 }
7212 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7213 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7214 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7215 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7216 }
7217 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7218 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7219 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7220 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7221 }
7222
7223 // hitShader
7224 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7225 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7226 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7227 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7228 }
7229 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7230 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7231 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7232 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7233 }
7234 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7235 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7236 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7237 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7238 }
7239
7240 // missShader
7241 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7242 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7243 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7244 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7245 }
7246 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7247 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7248 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7249 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7250 }
7251 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7252 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7253 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7254 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7255 }
7256
7257 // raygenShader
7258 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7259 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7260 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007261 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7262 }
7263 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7264 skip |=
7265 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7266 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7267 }
7268 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7269 skip |=
7270 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7271 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7272 }
7273 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7274 skip |=
7275 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7276 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007277 }
7278 return skip;
7279}
7280
sourav parmar83c31b12020-05-06 12:30:54 -07007281bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007282 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7283 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007284 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007285 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7286 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007287 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7288 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007289 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007290 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7291 }
7292 return skip;
7293}
7294
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007295bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7296 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007297 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007298 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007299
7300 if (!physical_device_features.multiViewport) {
7301 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007302 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7303 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007304 viewportCount);
7305 }
7306 } else { // multiViewport enabled
7307 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007308 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7309 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007310 ") must "
7311 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007312 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007313 }
7314 }
7315
7316 if (pViewports) {
7317 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7318 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007319 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007320 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007321 }
7322 }
7323
7324 return skip;
7325}
7326
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007327bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7328 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007329 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007330 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7331 return skip;
7332}
7333
7334bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7335 const VkViewport *pViewports) const {
7336 bool skip = false;
7337 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7338 return skip;
7339}
7340
7341bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7342 const VkRect2D *pScissors, bool is_ext) const {
7343 bool skip = false;
7344 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007345
7346 if (!physical_device_features.multiViewport) {
7347 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007348 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7349 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007350 ") must "
7351 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007352 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007353 }
7354 } else { // multiViewport enabled
7355 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007356 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7357 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007358 ") must "
7359 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007360 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007361 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007362 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7363 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007364 ") must "
7365 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007366 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007367 }
7368 }
7369
7370 if (pScissors) {
7371 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7372 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7373
7374 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007375 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7376 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007377 }
7378
7379 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007380 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7381 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007382 }
7383
7384 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7385 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007386 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7387 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7388 "] will overflow int32_t.",
7389 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007390 }
7391
7392 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7393 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007394 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7395 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7396 "] will overflow int32_t.",
7397 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7398 }
7399 }
7400 }
7401
7402 return skip;
7403}
7404
7405bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7406 const VkRect2D *pScissors) const {
7407 bool skip = false;
7408 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7409 return skip;
7410}
7411
7412bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7413 const VkRect2D *pScissors) const {
7414 bool skip = false;
7415 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7416 return skip;
7417}
7418
7419bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7420 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7421 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7422 bool is_2ext) const {
7423 bool skip = false;
7424 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7425 if (firstBinding >= device_limits.maxVertexInputBindings) {
7426 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7427 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7428 firstBinding, device_limits.maxVertexInputBindings);
7429 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7430 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7431 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7432 ") must be less than "
7433 "maxVertexInputBindings (%" PRIu32 ")",
7434 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7435 }
7436
7437 for (uint32_t i = 0; i < bindingCount; ++i) {
7438 if (pBuffers[i] == VK_NULL_HANDLE) {
7439 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7440 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7441 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7442 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7443 } else {
7444 if (pOffsets[i] != 0) {
7445 skip |=
7446 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7447 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7448 }
7449 }
7450 }
7451 if (pStrides) {
7452 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7453 skip |=
7454 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7455 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7456 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007457 }
7458 }
7459 }
7460
7461 return skip;
7462}
7463
7464bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7465 uint32_t bindingCount, const VkBuffer *pBuffers,
7466 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7467 const VkDeviceSize *pStrides) const {
7468 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007469 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7470 return skip;
7471}
Piers Daniell39842ee2020-07-10 16:42:33 -06007472
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007473bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7474 uint32_t bindingCount, const VkBuffer *pBuffers,
7475 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7476 const VkDeviceSize *pStrides) const {
7477 bool skip = false;
7478 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007479 return skip;
7480}
sourav parmarcd5fb182020-07-17 12:58:44 -07007481
7482bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7483 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7484 bool skip = false;
7485 for (uint32_t i = 0; i < infoCount; ++i) {
7486 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7487 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7488 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7489 }
7490 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7491 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7492 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7493 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7494 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7495 api_name);
7496 }
7497 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7498 skip |=
7499 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7500 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7501 }
7502 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7503 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7504 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7505 }
7506 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7507 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7508 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7509 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7510 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7511 api_name);
7512 }
7513 if (pInfos[i].pGeometries) {
7514 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7515 skip |= validate_ranged_enum(
7516 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7517 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7518 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7519 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007520 skip |= validate_struct_type(
7521 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7522 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7523 &(pInfos[i].pGeometries[j].geometry.triangles),
7524 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7525 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7526 skip |= validate_struct_pnext(
7527 api_name,
7528 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7529 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7530 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7531 skip |=
7532 validate_ranged_enum(api_name,
7533 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7534 ParameterName::IndexVector{i, j}),
7535 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7536 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7537 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7538 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7539 &pInfos[i].pGeometries[j].geometry.triangles,
7540 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7541 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7542 skip |= validate_ranged_enum(
7543 api_name,
7544 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7545 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7546 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7547
7548 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7549 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7550 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7551 }
7552 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7553 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7554 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7555 skip |=
7556 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7557 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7558 api_name);
7559 }
7560 }
7561 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7562 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7563 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7564 &pInfos[i].pGeometries[j].geometry.instances,
7565 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7566 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7567 skip |= validate_struct_type(
7568 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7569 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7570 &(pInfos[i].pGeometries[j].geometry.instances),
7571 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7572 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7573 skip |= validate_struct_pnext(
7574 api_name,
7575 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7576 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7577 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7578
7579 skip |= validate_bool32(api_name,
7580 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7581 ParameterName::IndexVector{i, j}),
7582 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7583 }
7584 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7585 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7586 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7587 &pInfos[i].pGeometries[j].geometry.aabbs,
7588 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7589 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7590 skip |= validate_struct_type(
7591 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7592 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7593 &(pInfos[i].pGeometries[j].geometry.aabbs),
7594 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7595 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7596 skip |= validate_struct_pnext(
7597 api_name,
7598 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7599 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7600 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7601 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7602 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7603 "(%s):stride must be less than or equal to 2^32-1", api_name);
7604 }
7605 }
7606 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7607 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7608 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7609 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7610 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7611 api_name);
7612 }
7613 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7614 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7615 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7616 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7617 "of elements of"
7618 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7619 api_name);
7620 }
7621 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7622 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7623 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7624 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7625 api_name);
7626 }
7627 }
7628 }
7629 }
7630 if (pInfos[i].ppGeometries != NULL) {
7631 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7632 skip |= validate_ranged_enum(
7633 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7634 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7635 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7636 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007637 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7638 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7639 &pInfos[i].ppGeometries[j]->geometry.triangles,
7640 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7641 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7642 skip |= validate_struct_type(
7643 api_name,
7644 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7645 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7646 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7647 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7648 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7649 skip |= validate_struct_pnext(
7650 api_name,
7651 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7652 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7653 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7654 skip |= validate_ranged_enum(api_name,
7655 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7656 ParameterName::IndexVector{i, j}),
7657 "VkFormat", AllVkFormatEnums,
7658 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7659 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7660 skip |= validate_ranged_enum(api_name,
7661 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7662 ParameterName::IndexVector{i, j}),
7663 "VkIndexType", AllVkIndexTypeEnums,
7664 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7665 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7666 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7667 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7668 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7669 }
7670 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7671 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7672 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7673 skip |=
7674 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7675 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7676 api_name);
7677 }
7678 }
7679 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7680 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7681 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7682 &pInfos[i].ppGeometries[j]->geometry.instances,
7683 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7684 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7685 skip |= validate_struct_type(
7686 api_name,
7687 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7688 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7689 &(pInfos[i].ppGeometries[j]->geometry.instances),
7690 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7691 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7692 skip |= validate_struct_pnext(
7693 api_name,
7694 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7695 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7696 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7697 skip |= validate_bool32(api_name,
7698 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7699 ParameterName::IndexVector{i, j}),
7700 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7701 }
7702 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7703 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7704 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7705 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7706 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7707 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7708 skip |= validate_struct_type(
7709 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7710 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7711 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7712 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7713 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7714 skip |= validate_struct_pnext(
7715 api_name,
7716 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7717 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7718 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7719 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7720 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7721 "(%s):stride must be less than or equal to 2^32-1", api_name);
7722 }
7723 }
7724 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7725 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7726 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7727 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7728 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7729 api_name);
7730 }
7731 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7732 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7733 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7734 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7735 "of elements of"
7736 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7737 api_name);
7738 }
7739 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7740 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7741 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7742 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7743 api_name);
7744 }
7745 }
7746 }
7747 }
7748 }
7749 return skip;
7750}
7751bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7752 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7753 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7754 bool skip = false;
7755 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7756 for (uint32_t i = 0; i < infoCount; ++i) {
7757 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7758 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7759 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7760 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7761 "scratchData.deviceAddress member must be a multiple of "
7762 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7763 }
7764 for (uint32_t k = 0; k < infoCount; ++k) {
7765 if (i == k) continue;
7766 bool found = false;
7767 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007768 skip |=
7769 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7770 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7771 ") of pInfos must "
7772 "not be "
7773 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7774 ") of pInfos.",
7775 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007776 found = true;
7777 }
7778 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007779 skip |=
7780 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7781 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7782 ") of pInfos must "
7783 "not be "
7784 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7785 ") of pInfos.",
7786 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007787 found = true;
7788 }
7789 if (found) break;
7790 }
7791 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7792 if (pInfos[i].pGeometries) {
7793 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7794 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7795 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7796 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7797 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7798 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7799 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7800 }
7801 } else {
7802 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7803 skip |=
7804 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7805 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7806 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7807 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7808 }
7809 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007810 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007811 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7812 skip |= LogError(
7813 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7814 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7815 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7816 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007817 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7818 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007819 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7820 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7821 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7822 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7823 }
7824 }
7825 } else if (pInfos[i].ppGeometries) {
7826 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7827 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7828 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7829 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7830 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7831 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7832 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7833 }
7834 } else {
7835 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7836 skip |=
7837 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7838 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7839 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7840 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7841 }
7842 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007843 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007844 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7845 skip |= LogError(
7846 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7847 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7848 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7849 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007850 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7851 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007852 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7853 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7854 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7855 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7856 }
7857 }
7858 }
7859 }
7860 }
7861 return skip;
7862}
7863
7864bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7865 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7866 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7867 const uint32_t *const *ppMaxPrimitiveCounts) const {
7868 bool skip = false;
7869 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7870 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007871 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007872 if (!ray_tracing_acceleration_structure_features ||
7873 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7874 skip |= LogError(
7875 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7876 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7877 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7878 }
7879 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007880 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7881 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7882 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7883 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7884 "scratchData.deviceAddress member must be a multiple of "
7885 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7886 }
7887 for (uint32_t k = 0; k < infoCount; ++k) {
7888 if (i == k) continue;
7889 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007890 skip |= LogError(
7891 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7892 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7893 ") "
7894 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7895 "any other element [%" PRIu32 ") of pInfos.",
7896 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007897 break;
7898 }
7899 }
7900 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7901 if (pInfos[i].pGeometries) {
7902 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7903 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7904 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7905 skip |= LogError(
7906 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7907 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7908 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7909 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7910 }
7911 } else {
7912 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7913 skip |= LogError(
7914 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7915 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7916 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7917 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7918 }
7919 }
7920 }
7921 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7922 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7923 skip |= LogError(
7924 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7925 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7926 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7927 }
7928 }
7929 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7930 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7931 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7932 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7933 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7934 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7935 }
7936 }
7937 } else if (pInfos[i].ppGeometries) {
7938 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7939 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7940 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7941 skip |= LogError(
7942 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7943 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7944 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7945 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7946 }
7947 } else {
7948 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7949 skip |= LogError(
7950 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7951 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7952 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7953 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7954 }
7955 }
7956 }
7957 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7958 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7959 skip |= LogError(
7960 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7961 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7962 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7963 }
7964 }
7965 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7966 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7967 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7968 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7969 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7970 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7971 }
7972 }
7973 }
7974 }
7975 }
7976 return skip;
7977}
7978
7979bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7980 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7981 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7982 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7983 bool skip = false;
7984 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7985 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007986 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007987 if (!ray_tracing_acceleration_structure_features ||
7988 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7989 skip |=
7990 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7991 "vkBuildAccelerationStructuresKHR: The "
7992 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7993 }
7994 for (uint32_t i = 0; i < infoCount; ++i) {
7995 for (uint32_t j = 0; j < infoCount; ++j) {
7996 if (i == j) continue;
7997 bool found = false;
7998 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007999 skip |=
8000 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8001 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
8002 ") of pInfos must "
8003 "not be "
8004 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8005 ") of pInfos.",
8006 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008007 found = true;
8008 }
8009 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008010 skip |=
8011 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
8012 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
8013 ") of pInfos must "
8014 "not be "
8015 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8016 ") of pInfos.",
8017 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008018 found = true;
8019 }
8020 if (found) break;
8021 }
8022 }
8023 return skip;
8024}
8025
8026bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
8027 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
8028 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
8029 bool skip = false;
8030 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
8031 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008032 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
8033 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01008034 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
8035 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008036 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01008037 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
8038 }
8039 if (pBuildInfo != nullptr) {
8040 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
8041 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
8042 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
8043 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
8044 }
sourav parmarcd5fb182020-07-17 12:58:44 -07008045 }
8046 return skip;
8047}
sfricke-samsungecafb192021-01-17 08:21:14 -08008048
Piers Daniellcb6d8032021-04-19 18:51:26 -06008049bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
8050 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
8051 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
8052 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
8053 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06008054 const auto *vertex_attribute_divisor_features =
8055 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
8056
Piers Daniellcb6d8032021-04-19 18:51:26 -06008057 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
8058 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
8059 skip |=
8060 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8061 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8062 }
8063
8064 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8065 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8066 skip |= LogError(
8067 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8068 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8069 }
8070
8071 // VUID-vkCmdSetVertexInputEXT-binding-04793
8072 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8073 bool binding_found = false;
8074 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8075 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8076 binding_found = true;
8077 break;
8078 }
8079 }
8080 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008081 skip |= LogError(
8082 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8083 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008084 }
8085 }
8086
8087 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8088 if (vertexBindingDescriptionCount > 1) {
8089 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8090 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8091 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8092 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8093 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008094 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8095 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008096 }
8097 }
8098 }
8099 }
8100
8101 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8102 if (vertexAttributeDescriptionCount > 1) {
8103 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8104 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8105 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8106 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8107 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008108 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8109 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008110 }
8111 }
8112 }
8113 }
8114
8115 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8116 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8117 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008118 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8119 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8120 "].binding is greater than maxVertexInputBindings",
8121 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008122 }
8123
8124 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8125 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008126 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8127 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8128 "].stride is greater than maxVertexInputBindingStride",
8129 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008130 }
8131
8132 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8133 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8134 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8135 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008136 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8137 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008138 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8139 binding);
8140 }
8141
8142 if (pVertexBindingDescriptions[binding].divisor > 1) {
8143 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8144 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8145 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008146 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8147 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008148 "vertexAttributeInstanceRateDivisor is not enabled",
8149 binding);
8150 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008151 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008152 if (pVertexBindingDescriptions[binding].divisor >
8153 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008154 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8155 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8156 "].divisor is greater than maxVertexAttribDivisor",
8157 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008158 }
8159
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008160 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008161 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008162 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8163 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8164 "].divisor is greater than 1 but inputRate "
8165 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8166 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008167 }
8168 }
8169 }
8170 }
8171
8172 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008173 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008174 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008175 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8176 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8177 "].location is greater than maxVertexInputAttributes",
8178 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008179 }
8180
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008181 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008182 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008183 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8184 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8185 "].binding is greater than maxVertexInputBindings",
8186 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008187 }
8188
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008189 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008190 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008191 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8192 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8193 "].offset is greater than maxVertexInputAttributeOffset",
8194 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008195 }
8196
8197 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8198 VkFormatProperties properties;
8199 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8200 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8201 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008202 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8203 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008204 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8205 attribute);
8206 }
8207 }
8208
8209 return skip;
8210}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008211
8212bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8213 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8214 const void *pValues) const {
8215 bool skip = false;
8216 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8217 // Check that offset + size don't exceed the max.
8218 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8219 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008220 skip |=
8221 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8222 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8223 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008224 }
8225 if (size > max_push_constants_size - offset) {
8226 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008227 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8228 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008229 offset, size, max_push_constants_size);
8230 }
8231
8232 // size needs to be non-zero and a multiple of 4.
8233 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008234 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8235 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008236 }
8237
8238 // offset needs to be a multiple of 4.
8239 if ((offset & 0x3) != 0) {
8240 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008241 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008242 }
8243 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008244}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008245
8246bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8247 uint32_t srcCacheCount,
8248 const VkPipelineCache *pSrcCaches) const {
8249 bool skip = false;
8250 if (pSrcCaches) {
8251 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8252 if (pSrcCaches[index0] == dstCache) {
8253 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8254 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8255 report_data->FormatHandle(dstCache).c_str());
8256 break;
8257 }
8258 }
8259 }
8260 return skip;
8261}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008262
8263bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8264 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8265 uint32_t rangeCount,
8266 const VkImageSubresourceRange *pRanges) const {
8267 bool skip = false;
8268 if (!pColor) {
8269 skip |=
8270 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8271 }
8272 return skip;
8273}
8274
8275bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8276 const VkRenderPassBeginInfo *const rp_begin) const {
8277 bool skip = false;
8278 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8279 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8280 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008281 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008282 func_name, rp_begin->clearValueCount);
8283 }
8284 return skip;
8285}
8286
8287bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8288 VkSubpassContents) const {
8289 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8290 return skip;
8291}
8292
8293bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8294 const VkRenderPassBeginInfo *pRenderPassBegin,
8295 const VkSubpassBeginInfo *) const {
8296 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8297 return skip;
8298}
8299
8300bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8301 const VkSubpassBeginInfo *) const {
8302 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8303 return skip;
8304}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008305
8306bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8307 uint32_t firstDiscardRectangle,
8308 uint32_t discardRectangleCount,
8309 const VkRect2D *pDiscardRectangles) const {
8310 bool skip = false;
8311
8312 if (pDiscardRectangles) {
8313 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8314 const int64_t x_sum =
8315 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8316 if (x_sum > std::numeric_limits<int32_t>::max()) {
8317 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8318 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8319 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8320 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8321 }
8322
8323 const int64_t y_sum =
8324 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8325 if (y_sum > std::numeric_limits<int32_t>::max()) {
8326 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8327 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8328 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8329 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8330 }
8331 }
8332 }
8333
8334 return skip;
8335}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008336
8337bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8338 uint32_t queryCount, size_t dataSize, void *pData,
8339 VkDeviceSize stride, VkQueryResultFlags flags) const {
8340 bool skip = false;
8341
8342 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8343 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8344 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8345 }
8346
8347 return skip;
8348}
ziga-lunargcf340c42021-08-19 00:13:38 +02008349
8350bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8351 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8352 bool skip = false;
8353
8354 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8355 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8356 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8357 ") is not a multiple of 4.",
8358 pConditionalRenderingBegin->offset);
8359 }
8360
8361 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008362}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008363
8364bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8365 VkSurfaceKHR surface,
8366 uint32_t *pSurfaceFormatCount,
8367 VkSurfaceFormatKHR *pSurfaceFormats) const {
8368 bool skip = false;
8369 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8370 skip |= LogError(
8371 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8372 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8373 }
8374 return skip;
8375}
8376
8377bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8378 VkSurfaceKHR surface,
8379 uint32_t *pPresentModeCount,
8380 VkPresentModeKHR *pPresentModes) const {
8381 bool skip = false;
8382 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8383 skip |= LogError(
8384 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8385 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8386 }
8387 return skip;
8388}
8389
8390bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8391 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8392 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8393 bool skip = false;
8394 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8395 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8396 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8397 "VK_GOOGLE_surfaceless_query is not enabled.");
8398 }
8399 return skip;
8400}
8401
8402bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8403 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8404 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8405 bool skip = false;
8406 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8407 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8408 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8409 "VK_GOOGLE_surfaceless_query is not enabled.");
8410 }
8411 return skip;
8412}
8413
8414#ifdef VK_USE_PLATFORM_WIN32_KHR
8415bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8416 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8417 VkPresentModeKHR *pPresentModes) const {
8418 bool skip = false;
8419 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8420 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8421 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8422 "VK_GOOGLE_surfaceless_query is not enabled.");
8423 }
8424 return skip;
8425}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008426
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008427#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008428
8429bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8430 const char *func_name) const {
8431 bool skip = false;
8432
8433 if (pInfo && pInfo->pCreateInfo) {
8434 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8435 if (image_swapchain_create_info) {
8436 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8437 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8438 }
8439 }
8440
8441 return skip;
8442}
8443
8444bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8445 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8446 bool skip = false;
8447
8448 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8449
8450 return skip;
8451}
8452
8453bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8454 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8455 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8456 bool skip = false;
8457
8458 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8459
8460 return skip;
8461}