blob: cc34298e02817e3833e1f052879bce7989f767b9 [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++) {
1256 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1257 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001258 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1259 "] (%s) and "
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001260 "VkImageCreateInfo::format (%s) are not compatible.",
Esther O'Keefed37c24b2021-09-27 12:45:40 +10001261 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001262 }
1263 }
1264 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001265 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001266
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001267 return skip;
1268}
1269
Jeff Bolz99e3f632020-03-24 22:59:22 -05001270bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1271 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1272 bool skip = false;
1273
1274 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001275 // Validate feature set if using CUBE_ARRAY
1276 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1277 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1278 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1279 "enabling the imageCubeArray feature.");
1280 }
1281
Jeff Bolz99e3f632020-03-24 22:59:22 -05001282 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1283 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1284 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001285 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1286 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001287 pCreateInfo->subresourceRange.layerCount);
1288 }
1289 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001290 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1291 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1292 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1293 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001294 }
1295 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001296
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001297 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001298 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001299 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1300 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1301 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1302 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1303 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1304 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1305 }
sfricke-samsunge3086292021-11-18 23:02:35 -08001306 if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) &&
1307 (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001308 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1309 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1310 "not an ASTC format.",
1311 string_VkFormat(pCreateInfo->format));
1312 }
1313 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001314
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001315 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001316 if (ycbcr_conversion != nullptr) {
1317 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1318 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1319 skip |= LogError(
1320 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1321 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1322 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1323 "r swizzle = %s\n"
1324 "g swizzle = %s\n"
1325 "b swizzle = %s\n"
1326 "a swizzle = %s\n",
1327 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1328 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1329 }
1330 }
1331 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001332 }
1333 return skip;
1334}
1335
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001336bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001337 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001338 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001339
1340 // Note: for numerical correctness
1341 // - float comparisons should expect NaN (comparison always false).
1342 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1343
1344 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001345 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001346 if (v1_f <= 0.0f) return true;
1347
1348 float intpart;
1349 const float fract = modff(v1_f, &intpart);
1350
1351 assert(std::numeric_limits<float>::radix == 2);
1352 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1353 if (intpart >= u32_max_plus1) return false;
1354
1355 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001356 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001357 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001358 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001359 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001360 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001361 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001362 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001363 };
1364
1365 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1366 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1367 return (v1_f <= v2_f);
1368 };
1369
1370 // width
1371 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001372 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001373
1374 if (!(viewport.width > 0.0f)) {
1375 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001376 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1377 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001378 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1379 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001380 skip |= LogError(object, "VUID-VkViewport-width-01771",
1381 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1382 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001383 }
1384
1385 // height
1386 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001387 const bool negative_height_enabled =
1388 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001389 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001390
1391 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1392 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001393 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1394 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001395 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1396 height_healthy = false;
1397
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001398 skip |= LogError(object, "VUID-VkViewport-height-01773",
1399 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1400 ").",
1401 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001402 }
1403
1404 // x
1405 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001406 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001407 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001408 skip |= LogError(object, "VUID-VkViewport-x-01774",
1409 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1410 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001411 }
1412
1413 // x + width
1414 if (x_healthy && width_healthy) {
1415 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001416 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001417 skip |= LogError(
1418 object, "VUID-VkViewport-x-01232",
1419 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1420 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1421 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001422 }
1423 }
1424
1425 // y
1426 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001427 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001428 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001429 skip |= LogError(object, "VUID-VkViewport-y-01775",
1430 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1431 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001432 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001433 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001434 skip |= LogError(object, "VUID-VkViewport-y-01776",
1435 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1436 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001437 }
1438
1439 // y + height
1440 if (y_healthy && height_healthy) {
1441 const float boundary = viewport.y + viewport.height;
1442
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001443 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001444 skip |= LogError(object, "VUID-VkViewport-y-01233",
1445 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1446 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1447 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001448 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001449 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001450 LogError(object, "VUID-VkViewport-y-01777",
1451 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1452 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1453 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001454 }
1455 }
1456
sfricke-samsungfd06d422021-01-22 02:17:21 -08001457 // 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 -07001458 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001459 // minDepth
1460 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001461 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001462 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001463 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1464 "[0.0, 1.0] range.",
1465 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001466 }
1467
1468 // maxDepth
1469 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001470 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001471 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001472 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1473 "[0.0, 1.0] range.",
1474 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001475 }
1476 }
1477
1478 return skip;
1479}
1480
Dave Houlton142c4cb2018-10-17 15:04:41 -06001481struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001482 VkShadingRatePaletteEntryNV shadingRate;
1483 uint32_t width;
1484 uint32_t height;
1485};
1486
1487// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001488static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001489 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1490 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1491 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1492 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1493 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1494 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001495};
1496
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001497bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001498 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001499
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001500 SampleOrderInfo *sample_order_info;
1501 uint32_t info_idx = 0;
1502 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1503 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1504 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001505 break;
1506 }
1507 }
1508
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001509 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001510 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1511 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1512 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001513 return skip;
1514 }
1515
Dave Houlton142c4cb2018-10-17 15:04:41 -06001516 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001517 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001518 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1519 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1520 ") must "
1521 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1522 "is set in framebufferNoAttachmentsSampleCounts.",
1523 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001524 }
1525
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001526 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001527 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1528 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1529 ") must "
1530 "be equal to the product of sampleCount (=%" PRIu32
1531 "), the fragment width for shadingRate "
1532 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001533 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001534 }
1535
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001536 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001537 skip |= LogError(
1538 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001539 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1540 ") must "
1541 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001542 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001543 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001544
1545 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001546 // the first width*height*sampleCount bits to all be set. Note: There is no
1547 // guarantee that 64 bits is enough, but practically it's unlikely for an
1548 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001549 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001550 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001551 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001552 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1553 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001554 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1555 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001556 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001557 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001558 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1559 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001560 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001561 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001562 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1563 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001564 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001565 uint32_t idx =
1566 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1567 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001568 }
1569
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001570 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1571 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001572 skip |= LogError(
1573 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001574 "The array pSampleLocations must contain exactly one entry for "
1575 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001576 }
1577
1578 return skip;
1579}
1580
sfricke-samsung51303fb2021-05-09 19:09:13 -07001581bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1582 const VkAllocationCallbacks *pAllocator,
1583 VkPipelineLayout *pPipelineLayout) const {
1584 bool skip = false;
1585 // Validate layout count against device physical limit
1586 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1587 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001588 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1589 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001590 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1591 }
1592
1593 // Validate Push Constant ranges
1594 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1595 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1596 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1597 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1598 // Check that offset + size don't exceed the max.
1599 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1600 if (offset >= max_push_constants_size) {
1601 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001602 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1603 ") that exceeds this "
1604 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001605 i, offset, max_push_constants_size);
1606 }
1607 if (size > max_push_constants_size - offset) {
1608 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001609 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1610 ") and size (%" PRIu32
1611 ") "
1612 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001613 i, offset, size, max_push_constants_size);
1614 }
1615
1616 // size needs to be non-zero and a multiple of 4.
1617 if (size == 0) {
1618 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001619 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1620 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001621 i, size);
1622 }
1623 if (size & 0x3) {
1624 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001625 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1626 ") is not a multiple of 4.",
1627 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001628 }
1629
1630 // offset needs to be a multiple of 4.
1631 if ((offset & 0x3) != 0) {
1632 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001633 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1634 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001635 i, offset);
1636 }
1637 }
1638
1639 // 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.
1640 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1641 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1642 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001643 skip |=
1644 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1645 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001646 }
1647 }
1648 }
1649 return skip;
1650}
1651
ziga-lunargc6341372021-07-28 12:57:42 +02001652bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1653 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1654 bool skip = false;
1655
1656 const auto *required_subgroup_size_features =
1657 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1658
1659 if (required_subgroup_size_features) {
1660 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1661 skip |= LogError(
1662 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1663 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1664 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1665 func_name, msg, pCreateInfo->flags);
1666 }
1667 }
1668
1669 return skip;
1670}
1671
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001672bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1673 uint32_t createInfoCount,
1674 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1675 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001676 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001677 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001678
1679 if (pCreateInfos != nullptr) {
1680 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001681 bool has_dynamic_viewport = false;
1682 bool has_dynamic_scissor = false;
1683 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001684 bool has_dynamic_depth_bias = false;
1685 bool has_dynamic_blend_constant = false;
1686 bool has_dynamic_depth_bounds = false;
1687 bool has_dynamic_stencil_compare = false;
1688 bool has_dynamic_stencil_write = false;
1689 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001690 bool has_dynamic_viewport_w_scaling_nv = false;
1691 bool has_dynamic_discard_rectangle_ext = false;
1692 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001693 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001694 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001695 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001696 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001697 bool has_dynamic_cull_mode = false;
1698 bool has_dynamic_front_face = false;
1699 bool has_dynamic_primitive_topology = false;
1700 bool has_dynamic_viewport_with_count = false;
1701 bool has_dynamic_scissor_with_count = false;
1702 bool has_dynamic_vertex_input_binding_stride = false;
1703 bool has_dynamic_depth_test_enable = false;
1704 bool has_dynamic_depth_write_enable = false;
1705 bool has_dynamic_depth_compare_op = false;
1706 bool has_dynamic_depth_bounds_test_enable = false;
1707 bool has_dynamic_stencil_test_enable = false;
1708 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001709 bool has_patch_control_points = false;
1710 bool has_rasterizer_discard_enable = false;
1711 bool has_depth_bias_enable = false;
1712 bool has_logic_op = false;
1713 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001714 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001715 if (pCreateInfos[i].pDynamicState != nullptr) {
1716 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1717 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1718 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001719 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1720 if (has_dynamic_viewport == true) {
1721 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1722 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001723 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001724 i);
1725 }
1726 has_dynamic_viewport = true;
1727 }
1728 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1729 if (has_dynamic_scissor == true) {
1730 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1731 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001732 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001733 i);
1734 }
1735 has_dynamic_scissor = true;
1736 }
1737 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1738 if (has_dynamic_line_width == true) {
1739 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1740 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001741 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001742 i);
1743 }
1744 has_dynamic_line_width = true;
1745 }
1746 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1747 if (has_dynamic_depth_bias == true) {
1748 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1749 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001750 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001751 i);
1752 }
1753 has_dynamic_depth_bias = true;
1754 }
1755 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1756 if (has_dynamic_blend_constant == true) {
1757 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1758 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001759 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001760 i);
1761 }
1762 has_dynamic_blend_constant = true;
1763 }
1764 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1765 if (has_dynamic_depth_bounds == true) {
1766 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1767 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001768 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001769 i);
1770 }
1771 has_dynamic_depth_bounds = true;
1772 }
1773 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1774 if (has_dynamic_stencil_compare == true) {
1775 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1776 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001777 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001778 i);
1779 }
1780 has_dynamic_stencil_compare = true;
1781 }
1782 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1783 if (has_dynamic_stencil_write == true) {
1784 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1785 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001786 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001787 i);
1788 }
1789 has_dynamic_stencil_write = true;
1790 }
1791 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1792 if (has_dynamic_stencil_reference == true) {
1793 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1794 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001795 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001796 i);
1797 }
1798 has_dynamic_stencil_reference = true;
1799 }
1800 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1801 if (has_dynamic_viewport_w_scaling_nv == true) {
1802 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1803 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001804 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001805 i);
1806 }
1807 has_dynamic_viewport_w_scaling_nv = true;
1808 }
1809 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1810 if (has_dynamic_discard_rectangle_ext == true) {
1811 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1812 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001813 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001814 i);
1815 }
1816 has_dynamic_discard_rectangle_ext = true;
1817 }
1818 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1819 if (has_dynamic_sample_locations_ext == true) {
1820 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1821 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001822 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001823 i);
1824 }
1825 has_dynamic_sample_locations_ext = true;
1826 }
1827 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1828 if (has_dynamic_exclusive_scissor_nv == true) {
1829 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1830 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001831 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001832 i);
1833 }
1834 has_dynamic_exclusive_scissor_nv = true;
1835 }
1836 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1837 if (has_dynamic_shading_rate_palette_nv == true) {
1838 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1839 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001840 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001841 i);
1842 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001843 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001844 }
1845 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1846 if (has_dynamic_viewport_course_sample_order_nv == true) {
1847 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1848 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001849 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001850 i);
1851 }
1852 has_dynamic_viewport_course_sample_order_nv = true;
1853 }
1854 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1855 if (has_dynamic_line_stipple == true) {
1856 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1857 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001858 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001859 i);
1860 }
1861 has_dynamic_line_stipple = true;
1862 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001863 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1864 if (has_dynamic_cull_mode) {
1865 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1866 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001867 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001868 i);
1869 }
1870 has_dynamic_cull_mode = true;
1871 }
1872 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1873 if (has_dynamic_front_face) {
1874 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1875 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001876 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001877 i);
1878 }
1879 has_dynamic_front_face = true;
1880 }
1881 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1882 if (has_dynamic_primitive_topology) {
1883 skip |= LogError(
1884 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1885 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001886 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001887 i);
1888 }
1889 has_dynamic_primitive_topology = true;
1890 }
1891 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1892 if (has_dynamic_viewport_with_count) {
1893 skip |= LogError(
1894 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1895 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001896 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001897 i);
1898 }
1899 has_dynamic_viewport_with_count = true;
1900 }
1901 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1902 if (has_dynamic_scissor_with_count) {
1903 skip |= LogError(
1904 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1905 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001906 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001907 i);
1908 }
1909 has_dynamic_scissor_with_count = true;
1910 }
1911 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1912 if (has_dynamic_vertex_input_binding_stride) {
1913 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1914 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1915 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001916 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001917 i);
1918 }
1919 has_dynamic_vertex_input_binding_stride = true;
1920 }
1921 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1922 if (has_dynamic_depth_test_enable) {
1923 skip |= LogError(
1924 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1925 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001926 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001927 i);
1928 }
1929 has_dynamic_depth_test_enable = true;
1930 }
1931 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1932 if (has_dynamic_depth_write_enable) {
1933 skip |= LogError(
1934 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1935 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001936 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001937 i);
1938 }
1939 has_dynamic_depth_write_enable = true;
1940 }
1941 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1942 if (has_dynamic_depth_compare_op) {
1943 skip |=
1944 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1945 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001946 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001947 i);
1948 }
1949 has_dynamic_depth_compare_op = true;
1950 }
1951 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1952 if (has_dynamic_depth_bounds_test_enable) {
1953 skip |= LogError(
1954 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1955 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001956 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001957 i);
1958 }
1959 has_dynamic_depth_bounds_test_enable = true;
1960 }
1961 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1962 if (has_dynamic_stencil_test_enable) {
1963 skip |= LogError(
1964 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1965 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001966 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001967 i);
1968 }
1969 has_dynamic_stencil_test_enable = true;
1970 }
1971 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1972 if (has_dynamic_stencil_op) {
1973 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1974 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001975 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001976 i);
1977 }
1978 has_dynamic_stencil_op = true;
1979 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001980 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1981 // Not allowed for graphics pipelines
1982 skip |= LogError(
1983 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1984 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001985 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
1986 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001987 i, state_index);
1988 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001989 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1990 if (has_patch_control_points) {
1991 skip |= LogError(
1992 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1993 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001994 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001995 i);
1996 }
1997 has_patch_control_points = true;
1998 }
1999 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2000 if (has_rasterizer_discard_enable) {
2001 skip |= LogError(
2002 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2003 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002004 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002005 i);
2006 }
2007 has_rasterizer_discard_enable = true;
2008 }
2009 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2010 if (has_depth_bias_enable) {
2011 skip |= LogError(
2012 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2013 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002014 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002015 i);
2016 }
2017 has_depth_bias_enable = true;
2018 }
2019 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2020 if (has_logic_op) {
2021 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2022 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002023 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002024 i);
2025 }
2026 has_logic_op = true;
2027 }
2028 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2029 if (has_primitive_restart_enable) {
2030 skip |= LogError(
2031 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2032 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002033 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002034 i);
2035 }
2036 has_primitive_restart_enable = true;
2037 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002038 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2039 if (has_dynamic_vertex_input) {
2040 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002041 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2042 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2043 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002044 }
2045 has_dynamic_vertex_input = true;
2046 }
Petr Kraus299ba622017-11-24 03:09:03 +01002047 }
2048 }
2049
sfricke-samsung3b944422021-01-23 02:15:19 -08002050 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2051 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2052 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002053 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2054 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002055 i);
2056 }
2057
2058 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2059 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2060 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002061 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002062 i);
2063 }
2064
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002065 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002066 if ((feedback_struct != nullptr) &&
2067 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002068 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
2069 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2070 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2071 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
2072 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002073 }
2074
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002075 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002076
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002077 // Collect active stages and other information
2078 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002079 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002080 bool has_eval = false;
2081 bool has_control = false;
2082 if (pCreateInfos[i].pStages != nullptr) {
2083 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
2084 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
2085
2086 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
2087 has_control = true;
2088 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
2089 has_eval = true;
2090 }
2091
2092 skip |= validate_string(
2093 "vkCreateGraphicsPipelines",
2094 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2095 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002096
2097 std::stringstream msg;
2098 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2099 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2100 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002101 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002102 }
2103
2104 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2105 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2106 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2107 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2108 pCreateInfos[i].pTessellationState,
2109 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2110 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2111
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002112 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002113 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2114
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002115 skip |= validate_struct_pnext(
2116 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2117 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2118 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2119 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2120 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2121 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002122
2123 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2124 pCreateInfos[i].pTessellationState->flags,
2125 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2126 }
2127
2128 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2129 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2130 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2131 pCreateInfos[i].pInputAssemblyState,
2132 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2133 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2134
2135 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2136 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002137 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002138
2139 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2140 pCreateInfos[i].pInputAssemblyState->flags,
2141 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2142
2143 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2144 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2145 pCreateInfos[i].pInputAssemblyState->topology,
2146 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2147
2148 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2149 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2150 }
2151
2152 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002153 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002154
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002155 if (pCreateInfos[i].pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002156 skip |=
2157 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2158 "vkCreateGraphicsPipelines: pararameter "
2159 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2160 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002161 }
2162
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002163 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002164 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2165 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2166 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2167 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002168 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2169 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002170 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002171 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2172 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002173 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002174 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2175 skip |=
2176 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2177 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2178 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2179 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2180 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2181
2182 skip |= validate_array(
2183 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2184 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2185 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2186 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2187
2188 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002189 for (uint32_t vertex_binding_description_index = 0;
2190 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2191 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002192 skip |= validate_ranged_enum(
2193 "vkCreateGraphicsPipelines",
2194 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2195 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002196 pCreateInfos[i]
2197 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2198 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002199 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2200 }
2201 }
2202
2203 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002204 for (uint32_t vertex_attribute_description_index = 0;
2205 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2206 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002207 const VkFormat format =
2208 pCreateInfos[i]
2209 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2210 .format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002211 skip |= validate_ranged_enum(
2212 "vkCreateGraphicsPipelines",
2213 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2214 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002215 pCreateInfos[i]
2216 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2217 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002218 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002219 if (FormatIsDepthOrStencil(format)) {
2220 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2221 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2222 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2223 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002224 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2225 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002226 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2227 "alignment, replace with a color format.",
2228 i, vertex_attribute_description_index, string_VkFormat(format));
2229 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002230 }
2231 }
2232
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002233 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002234 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2235 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002236 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2237 ") is "
2238 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002239 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002240 }
2241
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002242 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002243 skip |=
2244 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2245 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002246 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2247 ") is "
2248 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002249 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002250 }
2251
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002252 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2254 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002255 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2256 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002257 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2258 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002259 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2260 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002261 "(%" PRIu32 ") is not distinct.",
2262 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002263 }
2264 vertex_bindings.insert(vertex_bind_desc.binding);
2265
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002266 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002267 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2268 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002269 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2270 "].binding (%" PRIu32
2271 ") is "
2272 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002273 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002274 }
2275
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002276 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002277 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2278 "vkCreateGraphicsPipelines: parameter "
2279 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2280 "].stride (%" PRIu32
2281 ") is greater "
2282 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2283 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002284 }
2285 }
2286
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002287 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002288 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2289 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002290 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2291 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002292 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2293 "vkCreateGraphicsPipelines: parameter "
2294 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2295 "].location (%" PRIu32 ") is not distinct.",
2296 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002297 }
2298 attribute_locations.insert(vertex_attrib_desc.location);
2299
2300 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2301 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002302 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2303 "vkCreateGraphicsPipelines: parameter "
2304 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2305 "].binding (%" PRIu32
2306 ") does not exist "
2307 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2308 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002309 }
2310
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002311 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002312 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2313 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002314 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2315 "].location (%" PRIu32
2316 ") is "
2317 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002318 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002319 }
2320
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002321 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002322 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2323 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002324 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2325 "].binding (%" PRIu32
2326 ") is "
2327 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002328 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002329 }
2330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002331 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002332 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2333 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002334 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2335 "].offset (%" PRIu32
2336 ") is "
2337 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002338 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002339 }
2340 }
2341 }
2342
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002343 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2344 if (has_control && has_eval) {
2345 if (pCreateInfos[i].pTessellationState == nullptr) {
2346 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002347 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2348 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002349 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002350 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002351 i, i);
2352 } else {
2353 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2354 skip |= validate_struct_pnext(
2355 "vkCreateGraphicsPipelines",
2356 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2357 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2358 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2359 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002360
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002361 skip |= validate_reserved_flags(
2362 "vkCreateGraphicsPipelines",
2363 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2364 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002365
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002366 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2367 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2368 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2369 "vkCreateGraphicsPipelines: invalid parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002370 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2371 ". patchControlPoints "
2372 "should be >0 and <=%" PRIu32 ".",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002373 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2374 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002375 }
2376 }
2377 }
2378
2379 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2380 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2381 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2382 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002383 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2384 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2385 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2386 "].pViewportState (=NULL) is not a valid pointer.",
2387 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002388 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002389 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2390
2391 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002392 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2393 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2394 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2395 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002396 }
2397
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002398 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002399 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002400 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2401 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002402 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2403 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002404 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002405 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002406 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002407 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002408 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002409 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002410 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002411 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002412 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002413 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002414 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002415 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002416
2417 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002418 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002419 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002420 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002421
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002422 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002423 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002424 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002425 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002426 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002427 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2428 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002429 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002430 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2431 const auto depth_clip_control_struct =
2432 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002433
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002434 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002435 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002436 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2437 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2438 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2439 ") is not 1.",
2440 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002441 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002442
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002443 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002444 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2445 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2446 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2447 ") is not 1.",
2448 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002449 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002450
Dave Houlton142c4cb2018-10-17 15:04:41 -06002451 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2452 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002453 skip |= LogError(
2454 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2455 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2456 "disabled, but pCreateInfos[%" PRIu32
2457 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2458 ") is not 1.",
2459 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002460 }
2461
Jeff Bolz9af91c52018-09-01 21:53:57 -05002462 if (shading_rate_image_struct &&
2463 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002464 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2465 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2466 "disabled, but pCreateInfos[%" PRIu32
2467 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2468 ") is neither 0 nor 1.",
2469 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002470 }
2471
Petr Krausa6103552017-11-16 21:21:58 +01002472 } else { // multiViewport enabled
2473 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002474 if (!has_dynamic_viewport_with_count) {
2475 skip |= LogError(
2476 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2477 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2478 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002479 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002480 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2481 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2482 "].pViewportState->viewportCount (=%" PRIu32
2483 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2484 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002485 } else if (has_dynamic_viewport_with_count) {
2486 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2487 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2488 "].pViewportState->viewportCount (=%" PRIu32
2489 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2490 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002491 }
Petr Krausa6103552017-11-16 21:21:58 +01002492
2493 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002494 if (!has_dynamic_scissor_with_count) {
2495 skip |= LogError(
2496 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2497 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2498 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002499 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002500 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2501 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2502 "].pViewportState->scissorCount (=%" PRIu32
2503 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2504 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002505 } else if (has_dynamic_scissor_with_count) {
2506 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2507 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2508 "].pViewportState->scissorCount (=%" PRIu32
2509 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2510 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002511 }
2512 }
2513
ziga-lunarg845883b2021-07-14 15:05:00 +02002514 if (!has_dynamic_scissor && viewport_state.pScissors) {
2515 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2516 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002517
2518 if (scissor.offset.x < 0) {
2519 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2520 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2521 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2522 scissor.offset.x, i, scissor_i);
2523 }
2524
2525 if (scissor.offset.y < 0) {
2526 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2527 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2528 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2529 scissor.offset.y, i, scissor_i);
2530 }
2531
ziga-lunarg845883b2021-07-14 15:05:00 +02002532 const int64_t x_sum =
2533 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2534 if (x_sum > std::numeric_limits<int32_t>::max()) {
2535 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2536 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2537 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2538 "] will overflow int32_t.",
2539 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2540 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002541
ziga-lunarg845883b2021-07-14 15:05:00 +02002542 const int64_t y_sum =
2543 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2544 if (y_sum > std::numeric_limits<int32_t>::max()) {
2545 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2546 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2547 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2548 "] will overflow int32_t.",
2549 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2550 }
2551 }
2552 }
2553
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002554 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002555 skip |=
2556 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2557 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2558 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2559 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002560 }
2561
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002562 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002563 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2564 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2565 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2566 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2567 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002568 }
2569
Piers Daniell39842ee2020-07-10 16:42:33 -06002570 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2571 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002572 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2573 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2574 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2575 "].pViewportState->viewportCount (=%" PRIu32 ").",
2576 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002577 }
2578
Dave Houlton142c4cb2018-10-17 15:04:41 -06002579 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002580 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002581 skip |=
2582 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2583 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2584 ") must be zero or identical to pCreateInfos[%" PRIu32
2585 "].pViewportState->viewportCount (=%" PRIu32 ").",
2586 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002587 }
2588
Dave Houlton142c4cb2018-10-17 15:04:41 -06002589 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002590 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002591 skip |= LogError(
2592 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002593 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2594 "] "
2595 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2596 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2597 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002598 }
2599
Petr Krausa6103552017-11-16 21:21:58 +01002600 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002601 skip |= LogError(
2602 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002603 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2604 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002605 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2606 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002607 }
2608
2609 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002610 skip |= LogError(
2611 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002612 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2613 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002614 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2615 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002616 }
2617
Jeff Bolz3e71f782018-08-29 23:15:45 -05002618 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002619 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2620 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2621 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002622 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002623 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2624 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2625 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2626 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002627 }
2628
Jeff Bolz9af91c52018-09-01 21:53:57 -05002629 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002630 shading_rate_image_struct->viewportCount > 0 &&
2631 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002632 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002633 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002634 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002635 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2636 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002637 i, i);
2638 }
2639
Chris Mayer328d8212018-12-11 14:16:18 +01002640 if (vp_swizzle_struct) {
2641 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002642 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2643 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2644 " does "
2645 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2646 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002647 }
2648 }
2649
Petr Krausb3fcdb42018-01-09 22:09:09 +01002650 // validate the VkViewports
2651 if (!has_dynamic_viewport && viewport_state.pViewports) {
2652 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2653 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002654 const char *fn_name = "vkCreateGraphicsPipelines";
2655 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2656 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2657 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002658 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002659 }
2660 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002661
sfricke-samsung45996a42021-09-16 13:45:27 -07002662 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002663 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2664 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2665 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2666 "VK_NV_clip_space_w_scaling extension is not enabled.",
2667 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002668 }
2669
sfricke-samsung45996a42021-09-16 13:45:27 -07002670 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002671 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2672 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2673 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2674 "VK_EXT_discard_rectangles extension is not enabled.",
2675 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002676 }
2677
sfricke-samsung45996a42021-09-16 13:45:27 -07002678 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002679 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2680 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2681 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2682 "VK_EXT_sample_locations extension is not enabled.",
2683 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002684 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002685
sfricke-samsung45996a42021-09-16 13:45:27 -07002686 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002687 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2688 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2689 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2690 "VK_NV_scissor_exclusive extension is not enabled.",
2691 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002692 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002693
2694 if (coarse_sample_order_struct &&
2695 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2696 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002697 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2698 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2699 "] "
2700 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2701 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2702 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002703 }
2704
2705 if (coarse_sample_order_struct) {
2706 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002707 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002708 }
2709 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002710
2711 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2712 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002713 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2714 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2715 "] "
2716 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2717 ") "
2718 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2719 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002720 }
2721 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002722 skip |= LogError(
2723 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002724 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2725 "] "
2726 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2727 i);
2728 }
2729 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002730
2731 if (depth_clip_control_struct) {
2732 const auto *depth_clip_control_features =
2733 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2734 const bool enabled_depth_clip_control =
2735 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2736 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2737 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2738 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2739 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2740 "depthClipControl feature is not enabled. ",
2741 i);
2742 }
2743 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002744 }
2745
2746 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002747 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002748 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2749 "].pRasterizationState->rasterizerDiscardEnable "
2750 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002751 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002752 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002753 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002754 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002755 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2756 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002757 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002758 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002759 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002760 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002761 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002762 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002763 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002764 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2765 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002766
2767 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002768 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002769 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002770 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002771
2772 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002773 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002774 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2775 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2776
2777 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002778 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002779 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2780 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002781 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002782 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002783
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002784 skip |= validate_flags(
2785 "vkCreateGraphicsPipelines",
2786 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2787 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002788 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002789
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002790 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002791 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002792 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2793 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2794
2795 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002796 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002797 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2798 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2799
2800 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002801 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002802 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2803 "].pMultisampleState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002804 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2805 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002806 }
John Zulauf7acac592017-11-06 11:15:53 -07002807 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002808 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002809 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2810 "vkCreateGraphicsPipelines(): parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002811 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002812 i);
John Zulauf7acac592017-11-06 11:15:53 -07002813 }
2814 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2815 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2816 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002817 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002818
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002819 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2820 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2821 "].pMultisampleState->minSampleShading.",
2822 i);
John Zulauf7acac592017-11-06 11:15:53 -07002823 }
2824 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002825
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002826 const auto *line_state =
2827 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002828
2829 if (line_state) {
2830 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2831 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2832 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2833 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002834 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2835 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002836 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002837 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002838 }
2839 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2840 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002841 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2842 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002843 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002844 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002845 }
2846 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2847 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002848 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2849 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002850 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002851 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002852 }
2853 }
2854 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2855 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2856 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002857 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002858 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
2859 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002860 "range [1,256].",
2861 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002862 }
2863 }
2864 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002865 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002866 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2867 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002868 skip |=
2869 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002870 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2871 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002872 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2873 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002874 }
2875 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2876 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002877 skip |=
2878 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002879 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2880 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002881 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2882 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002883 }
2884 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2885 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002886 skip |=
2887 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002888 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2889 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002890 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2891 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002892 }
2893 if (line_state->stippledLineEnable) {
2894 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2895 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002896 skip |=
2897 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002898 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2899 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002900 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2901 "stippledRectangularLines feature.",
2902 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002903 }
2904 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2905 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002906 skip |=
2907 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002908 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2909 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002910 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2911 "stippledBresenhamLines feature.",
2912 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002913 }
2914 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2915 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002916 skip |=
2917 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002918 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2919 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002920 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2921 "stippledSmoothLines feature.",
2922 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002923 }
2924 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05002925 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002926 skip |=
2927 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002928 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2929 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002930 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2931 "stippledRectangularLines and strictLines features.",
2932 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002933 }
2934 }
2935 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002936 }
2937
Petr Krause91f7a12017-12-14 20:57:36 +01002938 bool uses_color_attachment = false;
2939 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00002940 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01002941 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002942 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002943 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2944 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002945 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002946 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002947 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002948 }
2949 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002950 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002951 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00002952 subpass_flags = subpasses_uses.subpasses_flags[pCreateInfos[i].subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01002953 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002954 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002955 }
2956
2957 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002959 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002960 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002961 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002962 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002963
Mike Schuchardt00e81452021-11-29 11:11:20 -08002964 skip |=
2965 validate_flags("vkCreateGraphicsPipelines",
2966 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
2967 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
2968 pCreateInfos[i].pDepthStencilState->flags, kOptionalFlags,
2969 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970
2971 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002972 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2974 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2975
2976 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002977 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002978 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2979 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2980
2981 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002982 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002983 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2984 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002985 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002986
2987 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002988 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2990 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2991
2992 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002993 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002994 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2995 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2996
2997 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002998 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002999 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
3000 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003001 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003002
3003 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003004 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003005 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
3006 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003007 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003008
3009 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003010 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003011 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
3012 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003013 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003014
3015 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003016 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003017 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
3018 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003019 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003020
3021 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003022 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003023 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
3024 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003025 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003026
3027 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003028 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003029 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
3030 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003031 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003032
3033 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003034 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003035 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
3036 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003037 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003038
3039 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003040 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003041 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
3042 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003043 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003044
3045 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003046 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003047 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3048 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003049 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3050 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003051 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003052
3053 if ((pCreateInfos[i].pDepthStencilState->flags &
3054 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3055 const auto *rasterization_order_attachment_access_feature =
3056 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3057 const bool rasterization_order_depth_attachment_access_feature_enabled =
3058 rasterization_order_attachment_access_feature &&
3059 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3060 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3061 skip |= LogError(
3062 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3063 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3064 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3065 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
3066 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str());
3067 }
3068
3069 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3070 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003071 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003072 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3073 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3074 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str(),
3075 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3076 }
3077 }
3078
3079 if ((pCreateInfos[i].pDepthStencilState->flags &
3080 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3081 const auto *rasterization_order_attachment_access_feature =
3082 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3083 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3084 rasterization_order_attachment_access_feature &&
3085 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3086 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3087 skip |= LogError(
3088 device,
3089 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3090 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3091 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3092 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
3093 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str());
3094 }
3095
3096 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3097 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003098 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003099 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3100 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3101 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str(),
3102 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3103 }
3104 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003105 }
3106
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003107 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003108 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3109 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003110
Petr Krause91f7a12017-12-14 20:57:36 +01003111 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003112 skip |= validate_struct_type("vkCreateGraphicsPipelines",
3113 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3114 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3115 pCreateInfos[i].pColorBlendState,
3116 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
3117 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
3118
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003119 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003120 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003121 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
ziga-lunarg8de09162021-08-05 15:21:33 +02003122 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003123 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
3124 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003125 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3126 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003127
Mike Schuchardt00e81452021-11-29 11:11:20 -08003128 skip |= validate_flags("vkCreateGraphicsPipelines",
3129 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3130 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
3131 pCreateInfos[i].pColorBlendState->flags, kOptionalFlags,
3132 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003133
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003134 if ((pCreateInfos[i].pColorBlendState->flags &
3135 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3136 const auto *rasterization_order_attachment_access_feature =
3137 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3138 const bool rasterization_order_color_attachment_access_feature_enabled =
3139 rasterization_order_attachment_access_feature &&
3140 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3141
3142 if (!rasterization_order_color_attachment_access_feature_enabled) {
3143 skip |= LogError(
3144 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3145 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3146 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3147 "VkPipelineColorBlendStateCreateInfo::flags == %s",
3148 string_VkPipelineColorBlendStateCreateFlags(pCreateInfos[i].pColorBlendState->flags).c_str());
3149 }
3150
3151 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
3152 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003153 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003154 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3155 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3156 string_VkPipelineColorBlendStateCreateFlags(pCreateInfos[i].pColorBlendState->flags).c_str(),
3157 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3158 }
3159 }
3160
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003161 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003162 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003163 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
3164 pCreateInfos[i].pColorBlendState->logicOpEnable);
3165
3166 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003167 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003168 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3169 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00003170 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06003171 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003172
3173 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003174 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
3175 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003176 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003177 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003178 ParameterName::IndexVector{i, attachment_index}),
3179 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003180
3181 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003182 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003183 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003184 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003185 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003186 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003187 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003188
3189 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003190 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003191 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003192 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003193 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003194 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003195 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003196
3197 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003198 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003199 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003200 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003201 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003202 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003203 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003204
3205 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003206 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003207 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003208 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003209 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003210 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003211 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003212
3213 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003214 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003215 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003216 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003218 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003219 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003220
3221 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003222 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003223 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003224 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003225 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003226 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003227 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003228
3229 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003230 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003231 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003232 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003233 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003234 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003235 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003236
3237 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3238 bool invalid = false;
3239 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3240 case VK_BLEND_OP_ZERO_EXT:
3241 case VK_BLEND_OP_SRC_EXT:
3242 case VK_BLEND_OP_DST_EXT:
3243 case VK_BLEND_OP_SRC_OVER_EXT:
3244 case VK_BLEND_OP_DST_OVER_EXT:
3245 case VK_BLEND_OP_SRC_IN_EXT:
3246 case VK_BLEND_OP_DST_IN_EXT:
3247 case VK_BLEND_OP_SRC_OUT_EXT:
3248 case VK_BLEND_OP_DST_OUT_EXT:
3249 case VK_BLEND_OP_SRC_ATOP_EXT:
3250 case VK_BLEND_OP_DST_ATOP_EXT:
3251 case VK_BLEND_OP_XOR_EXT:
3252 case VK_BLEND_OP_INVERT_EXT:
3253 case VK_BLEND_OP_INVERT_RGB_EXT:
3254 case VK_BLEND_OP_LINEARDODGE_EXT:
3255 case VK_BLEND_OP_LINEARBURN_EXT:
3256 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3257 case VK_BLEND_OP_LINEARLIGHT_EXT:
3258 case VK_BLEND_OP_PINLIGHT_EXT:
3259 case VK_BLEND_OP_HARDMIX_EXT:
3260 case VK_BLEND_OP_PLUS_EXT:
3261 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3262 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3263 case VK_BLEND_OP_PLUS_DARKER_EXT:
3264 case VK_BLEND_OP_MINUS_EXT:
3265 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3266 case VK_BLEND_OP_CONTRAST_EXT:
3267 case VK_BLEND_OP_INVERT_OVG_EXT:
3268 case VK_BLEND_OP_RED_EXT:
3269 case VK_BLEND_OP_GREEN_EXT:
3270 case VK_BLEND_OP_BLUE_EXT:
3271 invalid = true;
3272 break;
3273 default:
3274 break;
3275 }
3276 if (invalid) {
3277 skip |= LogError(
3278 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3279 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3280 "].pColorBlendState->pAttachments[%" PRIu32
3281 "].colorBlendOp (%s) is not valid when "
3282 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3283 "VK_FALSE",
3284 i, attachment_index,
3285 string_VkBlendOp(
3286 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3287 }
3288 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003289 }
3290 }
3291
3292 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003293 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003294 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3295 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003296 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3297 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003298 }
3299
3300 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3301 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3302 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003303 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003304 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003305 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3306 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003307 }
3308 }
3309 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003310
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003311 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3312 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003313 if (pCreateInfos[i].basePipelineIndex != -1) {
3314 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003315 skip |=
3316 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003317 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3318 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003319 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003320 "and pCreateInfos->basePipelineIndex is not -1.",
3321 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003322 }
3323 }
3324
Petr Kraus9752aae2017-11-24 03:05:50 +01003325 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3326 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003327 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003328 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3329 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003330 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003331 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3332 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003333 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003334 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003335 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003336 skip |=
3337 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003338 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3339 ") must be a valid"
3340 "index into the pCreateInfos array, of size %" PRIu32 ".",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003341 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003342 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003343 }
3344 }
3345
Petr Kraus9752aae2017-11-24 03:05:50 +01003346 if (pCreateInfos[i].pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003347 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003348 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3349 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003350 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3351 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3352 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3353 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003354 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3355 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003356 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003357 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003358 "pCreateInfos[%" PRIu32
3359 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003360 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3361 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003362 }
3363 } else {
3364 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3365 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3366 (physical_device_features.fillModeNonSolid == false)) {
3367 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003368 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3369 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003370 "pCreateInfos[%" PRIu32
3371 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003372 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3373 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003374 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003375 }
Petr Kraus299ba622017-11-24 03:09:03 +01003376
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003377 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003378 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003379 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3380 "The line width state is static (pCreateInfos[%" PRIu32
3381 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3382 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3383 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3384 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003385 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003386 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003387
3388 // Validate no flags not allowed are used
3389 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003390 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003391 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3392 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003393 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3394 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003395 }
3396 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003397 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003398 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3399 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003400 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3401 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003402 }
3403 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3404 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003405 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3406 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003407 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3408 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003409 }
3410 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3411 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003412 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3413 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003414 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3415 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003416 }
3417 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3418 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003419 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3420 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003421 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3422 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003423 }
3424 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3425 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003426 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3427 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003428 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3429 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003430 }
3431 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3432 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003433 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3434 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003435 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3436 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003437 }
3438 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3439 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003440 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3441 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003442 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3443 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003444 }
3445 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3446 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003447 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3448 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003449 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3450 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003451 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003452 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3453 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3454 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3455 "]->flags (0x%x) must not include "
3456 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3457 i, flags);
3458 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003459 }
3460 }
3461
3462 return skip;
3463}
3464
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003465bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3466 uint32_t createInfoCount,
3467 const VkComputePipelineCreateInfo *pCreateInfos,
3468 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003469 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003470 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003471 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003472 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003473 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003474 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003475 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003476 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003477 skip |=
3478 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3479 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3480 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3481 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003482 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003483
3484 // Make sure compute stage is selected
3485 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003486 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003487 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3488 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003489 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003490 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003491
sfricke-samsungeb549012021-04-16 01:25:51 -07003492 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3493 // Validate no flags not allowed are used
3494 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003495 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3496 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3497 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3498 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003499 }
3500 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3501 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003502 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3503 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003504 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3505 i, flags);
3506 }
3507 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3508 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003509 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3510 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003511 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3512 i, flags);
3513 }
3514 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3515 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003516 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3517 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003518 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3519 i, flags);
3520 }
3521 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3522 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003523 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3524 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003525 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3526 i, flags);
3527 }
3528 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3529 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003530 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3531 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003532 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3533 i, flags);
3534 }
3535 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3536 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003537 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3538 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003539 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3540 i, flags);
3541 }
3542 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3543 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003544 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3545 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003546 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3547 i, flags);
3548 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003549 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3550 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003551 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3552 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003553 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3554 i, flags);
3555 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003556 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3557 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003558 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3559 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003560 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3561 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003562 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003563 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3564 if (pCreateInfos[i].basePipelineIndex != -1) {
3565 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3566 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3567 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3568 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3569 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3570 i);
3571 }
3572 }
3573
3574 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3575 if (pCreateInfos[i].basePipelineIndex != -1) {
3576 skip |= LogError(
3577 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3578 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3579 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3580 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3581 i);
3582 }
3583 } else {
3584 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3585 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3586 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3587 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3588 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3589 }
3590 }
3591 }
ziga-lunargc6341372021-07-28 12:57:42 +02003592
3593 std::stringstream msg;
3594 msg << "pCreateInfos[%" << i << "].stage";
3595 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003596 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003597 return skip;
3598}
3599
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003600bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003601 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003602 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003603
3604 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003605 const auto &features = physical_device_features;
3606 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003607
John Zulauf71968502017-10-26 13:51:15 -06003608 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3609 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003610 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3611 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3612 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3613 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003614 }
3615
3616 // Anistropy cannot be enabled in sampler unless enabled as a feature
3617 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003618 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3619 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3620 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003621 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003622 }
John Zulauf71968502017-10-26 13:51:15 -06003623
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003624 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3625 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003626 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3627 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3628 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3629 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003630 }
3631 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003632 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3633 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3634 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3635 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003636 }
3637 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003638 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3639 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3640 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3641 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003642 }
3643 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3644 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3645 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3646 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003647 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3648 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3649 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3650 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3651 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3652 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003653 }
3654 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003655 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3656 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3657 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003658 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003659 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003660 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3661 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3662 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003663 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003664 }
3665
3666 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3667 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003668 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3669 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003670 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003671 if (sampler_reduction != nullptr) {
3672 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3673 skip |= LogError(
3674 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3675 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3676 }
3677 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003678 }
3679
3680 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3681 // valid VkBorderColor value
3682 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3683 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3684 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003685 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3686 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003687 }
3688
John Zulauf275805c2017-10-26 15:34:49 -06003689 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003690 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003691 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3692 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003693 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3694 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3695 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003696 }
3697 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003698
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003699 // Check for valid Lod range
3700 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003701 skip |=
3702 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3703 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003704 }
3705
3706 // Check mipLodBias to device limit
3707 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003708 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3709 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3710 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003711 }
3712
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003713 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003714 if (sampler_conversion != nullptr) {
3715 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3716 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3717 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3718 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003719 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003720 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003721 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3722 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3723 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3724 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3725 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3726 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3727 }
3728 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003729
3730 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3731 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3732 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3733 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3734 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3735 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3736 }
3737 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3738 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3739 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3740 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3741 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3742 }
3743 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3744 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3745 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3746 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3747 pCreateInfo->minLod, pCreateInfo->maxLod);
3748 }
3749 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3750 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3751 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3752 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3753 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3754 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3755 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3756 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3757 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3758 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3759 }
3760 if (pCreateInfo->anisotropyEnable) {
3761 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3762 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3763 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3764 }
3765 if (pCreateInfo->compareEnable) {
3766 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3767 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3768 "pCreateInfo->compareEnable must be VK_FALSE");
3769 }
3770 if (pCreateInfo->unnormalizedCoordinates) {
3771 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3772 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3773 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3774 }
3775 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003776
Piers Daniell833b9492021-11-20 11:47:10 -07003777 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3778 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3779 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
3780 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3781 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3782 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3783 }
3784 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
3785 if (!custom_create_info) {
3786 skip |= LogError(
3787 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3788 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3789 "struct in pNext chain.\n",
3790 string_VkBorderColor(pCreateInfo->borderColor));
3791 } else {
3792 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3793 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
3794 !FormatIsSampledInt(custom_create_info->format)) ||
3795 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3796 !FormatIsSampledFloat(custom_create_info->format)))) {
3797 skip |=
3798 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06003799 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3800 "whose type does not match\n",
3801 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07003802 ;
3803 }
3804 }
3805 }
3806
3807 const auto *border_color_component_mapping =
3808 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
3809 if (border_color_component_mapping) {
3810 const auto *border_color_swizzle_features =
3811 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
3812 bool border_color_swizzle_features_enabled =
3813 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
3814 if (!border_color_swizzle_features_enabled) {
3815 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
3816 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
3817 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06003818 }
3819 }
3820 }
3821
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003822 return skip;
3823}
3824
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003825bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
3826 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
3827 const char *func_name) const {
3828 bool skip = false;
3829
3830 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
3831 uint32_t mutable_type_count = 0;
3832 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
3833 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
3834 }
3835 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3836 if (mutable_type_count == 0) {
3837 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
3838 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3839 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
3840 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3841 "].descriptorTypeCount is 0.",
3842 func_name, i, i);
3843 }
3844 } else {
3845 if (mutable_type_count > 0) {
3846 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
3847 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3848 "].descriptorType is %s, but "
3849 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3850 "].descriptorTypeCount is not 0.",
3851 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
3852 }
3853 }
3854 }
3855
3856 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
3857 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
3858 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
3859 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
3860 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
3861 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3862 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
3863 func_name, j, k);
3864 break;
3865 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
3866 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
3867 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3868 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
3869 func_name, j, k);
3870 break;
3871 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
3872 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
3873 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3874 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
3875 func_name, j, k);
3876 break;
3877 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
3878 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
3879 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3880 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
3881 func_name, j, k);
3882 break;
3883 default:
3884 break;
3885 }
3886 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
3887 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
3888 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
3889 skip |=
3890 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
3891 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3892 "].pDescriptorTypes[%" PRIu32
3893 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3894 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
3895 func_name, j, k, j, l,
3896 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
3897 }
3898 }
3899 }
3900 }
3901
3902 return skip;
3903}
3904
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003905bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3906 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3907 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003908 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003909 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003910
ziga-lunargfc6896f2021-10-15 18:46:12 +02003911 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
3912 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
3913 bool mutable_descriptor_type_features_enabled =
3914 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
3915
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003916 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3917 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3918 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3919 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003920 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3921 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3922 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3923 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3924 ++descriptor_index) {
3925 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003926 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003927 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003928 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
3929 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003930 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003931 }
3932 }
3933 }
3934
3935 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3936 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3937 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003938 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003939 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3940 "].descriptorCount is not 0, "
3941 "pCreateInfo->pBindings[%" PRIu32
3942 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003943 "values.",
3944 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003945 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003946
3947 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3948 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3949 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003950 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3951 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3952 "].descriptorCount is not 0 and "
3953 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
3954 "].stageFlags "
3955 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3956 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003957 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02003958
3959 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3960 if (!mutable_descriptor_type) {
3961 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
3962 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3963 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3964 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
3965 i);
3966 }
3967 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
3968 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
3969 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3970 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3971 "pImmutableSamplers is not NULL.",
3972 i);
3973 }
3974 if (!mutable_descriptor_type_features_enabled) {
3975 skip |= LogError(
3976 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
3977 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3978 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3979 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
3980 i);
3981 }
3982 }
3983
3984 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
3985 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3986 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
3987 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
3988 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
3989 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
3990 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003991 }
3992 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003993
3994 if (mutable_descriptor_type) {
3995 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
3996 "vkDescriptorSetLayoutCreateInfo");
3997 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003998 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02003999 if (pCreateInfo) {
4000 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4001 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4002 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4003 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4004 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4005 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4006 }
4007 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4008 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4009 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4010 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4011 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4012 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4013 }
4014 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4015 !mutable_descriptor_type_features_enabled) {
4016 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4017 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4018 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4019 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4020 }
4021 }
4022
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004023 return skip;
4024}
4025
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004026bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4027 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004028 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004029 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4030 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4031 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004032 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4033 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004034}
4035
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004036bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4037 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004038 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004039 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004040
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004041 if (pDescriptorWrites != NULL) {
4042 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4043 // descriptorCount must be greater than 0
4044 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004045 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4046 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4047 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004048 }
4049
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004050 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004051 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004052 // dstSet must be a valid VkDescriptorSet handle
4053 skip |= validate_required_handle(vkCallingFunction,
4054 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4055 pDescriptorWrites[i].dstSet);
4056 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004057
4058 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4059 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4060 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4061 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4062 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004063 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004064 if (!isPushDescriptor) {
4065 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4066 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4067 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4068 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4069 // ObjectLifetimes::ValidateDescriptorWrite.
4070 skip |= LogError(
4071 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4072 "%s(): if pDescriptorWrites[%" PRIu32
4073 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4074 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4075 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4076 vkCallingFunction, i, i);
4077 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4078 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4079 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4080 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4081 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4082 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4083 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4084 "%s(): if pDescriptorWrites[%" PRIu32
4085 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4086 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4087 "].pImageInfo must not be NULL.",
4088 vkCallingFunction, i, i);
4089 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004090 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4091 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004092 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4093 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004094 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4095 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004096 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004097 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4098 ParameterName::IndexVector{i, descriptor_index}),
4099 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004100 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004101 }
4102 }
4103 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4104 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4105 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4106 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4107 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4108 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4109 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004110 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004111 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004112 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004113 "%s(): if pDescriptorWrites[%" PRIu32
4114 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004115 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4116 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004117 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004118 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004119 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004120 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004121 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004122 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004123 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4124 ++descriptor_index) {
4125 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4126 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4127 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004128 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004129 "%s(): if pDescriptorWrites[%" PRIu32
4130 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004131 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004132 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4133 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004134 }
4135 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004136 }
4137 }
4138 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4139 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004140 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004141 }
4142
4143 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4144 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004145 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004146 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4147 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004148 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004149 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004150 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004151 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004152 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004153 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004154 }
4155 }
4156 }
4157 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4158 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004159 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004160 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4161 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004162 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004163 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004164 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004165 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004166 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004167 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004168 }
4169 }
4170 }
4171 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004172 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4173 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004174 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004175 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004176 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4177 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4178 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4179 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004180 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004181 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4182 pDescriptorWrites[i].descriptorCount);
4183 }
4184 // further checks only if we have right structtype
4185 if (pnext_struct) {
4186 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4187 skip |= LogError(
4188 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004189 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4190 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004191 ".",
4192 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004193 }
sourav parmarbcee7512020-12-28 14:34:49 -08004194 if (pnext_struct->accelerationStructureCount == 0) {
4195 skip |= LogError(device,
4196 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004197 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004198 }
4199 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004200 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004201 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4202 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4203 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4204 skip |= LogError(device,
4205 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4206 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004207 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004208 }
4209 }
4210 }
sourav parmarbcee7512020-12-28 14:34:49 -08004211 }
4212 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004213 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004214 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4215 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4216 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4217 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004218 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004219 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4220 pDescriptorWrites[i].descriptorCount);
4221 }
4222 // further checks only if we have right structtype
4223 if (pnext_struct) {
4224 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4225 skip |= LogError(
4226 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004227 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4228 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004229 ".",
4230 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004231 }
sourav parmarbcee7512020-12-28 14:34:49 -08004232 if (pnext_struct->accelerationStructureCount == 0) {
4233 skip |= LogError(device,
4234 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004235 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004236 }
4237 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004238 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004239 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4240 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4241 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4242 skip |= LogError(device,
4243 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4244 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004245 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004246 }
4247 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004248 }
4249 }
4250 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004251 }
4252 }
4253 return skip;
4254}
4255
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004256bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4257 const VkWriteDescriptorSet *pDescriptorWrites,
4258 uint32_t descriptorCopyCount,
4259 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004260 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004261}
4262
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004263bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004264 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004265 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004266 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4267}
4268
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004269bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4270 const VkAllocationCallbacks *pAllocator,
4271 VkRenderPass *pRenderPass) const {
4272 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4273}
4274
Mike Schuchardt2df08912020-12-15 16:28:09 -08004275bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004276 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004277 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004278 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4279}
4280
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004281bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4282 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004283 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004284 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004285
4286 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4287 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4288 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004289 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4290 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004291 return skip;
4292}
4293
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004294bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004295 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004296 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004297
4298 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4299 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004300 bool cb_is_secondary;
4301 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004302 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004303 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4304 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004305
Tony-LunarG3c287f62020-12-17 12:39:49 -07004306 if (cb_is_secondary) {
4307 // Implicit VUs
4308 // validate only sType here; pointer has to be validated in core_validation
4309 const bool k_not_required = false;
4310 const char *k_no_vuid = nullptr;
4311 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4312 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004313 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4314 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004315
Tony-LunarG3c287f62020-12-17 12:39:49 -07004316 if (info) {
4317 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004318 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004319 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4320 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004321 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004322 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004323 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4324 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4325 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4326 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004327
Tony-LunarG3c287f62020-12-17 12:39:49 -07004328 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004329
Tony-LunarG3c287f62020-12-17 12:39:49 -07004330 // Explicit VUs
4331 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004332 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004333 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4334 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4335 cmd_name);
4336 }
4337
4338 if (physical_device_features.inheritedQueries) {
4339 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004340 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4341 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4342 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004343 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004344 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004345 }
4346
4347 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004348 skip |=
4349 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4350 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4351 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4352 } else { // !pipelineStatisticsQuery
4353 skip |=
4354 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4355 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004356 }
4357
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004358 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004359 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004360 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004361 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4362 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4363 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004364 commandBuffer,
4365 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004366 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4367 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4368 }
Petr Kraus139757b2019-08-15 17:19:33 +02004369 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004370
4371 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4372 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4373 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4374 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4375 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4376 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4377 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4378 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4379 }
Petr Kraus139757b2019-08-15 17:19:33 +02004380 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004381 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004382 return skip;
4383}
4384
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004385bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004386 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004387 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004388
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004389 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004390 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004391 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4392 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4393 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004394 }
4395 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004396 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4397 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4398 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004399 }
4400 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004401 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004402 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004403 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4404 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4405 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4406 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004407 }
4408 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004409
4410 if (pViewports) {
4411 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4412 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004413 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004414 skip |= manual_PreCallValidateViewport(
4415 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004416 }
4417 }
4418
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004419 return skip;
4420}
4421
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004422bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004423 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004424 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004425
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004426 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004427 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004428 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4429 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4430 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004431 }
4432 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004433 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4434 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4435 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004436 }
4437 } else { // multiViewport enabled
4438 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004439 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004440 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4441 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4442 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4443 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004444 }
4445 }
4446
Petr Kraus6260f0a2018-02-27 21:15:55 +01004447 if (pScissors) {
4448 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4449 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004450
Petr Kraus6260f0a2018-02-27 21:15:55 +01004451 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004452 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4453 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4454 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004455 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004456
Petr Kraus6260f0a2018-02-27 21:15:55 +01004457 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004458 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4459 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4460 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004461 }
4462
4463 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4464 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004465 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4466 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4467 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4468 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004469 }
4470
4471 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4472 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004473 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4474 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4475 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4476 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004477 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004478 }
4479 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004480
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004481 return skip;
4482}
4483
Jeff Bolz5c801d12019-10-09 10:38:45 -05004484bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004485 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004486
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004487 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004488 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4489 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004490 }
4491
4492 return skip;
4493}
4494
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004495bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004496 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004497 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004498
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004499 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004500 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004501 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4502 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004503 }
4504 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004505 skip |=
4506 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4507 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4508 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004509 }
4510 return skip;
4511}
4512
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004513bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004514 VkDeviceSize offset, uint32_t drawCount,
4515 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004516 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004517 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004518 skip |=
4519 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4520 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4521 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004522 }
4523 if (drawCount > device_limits.maxDrawIndirectCount) {
4524 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004525 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4526 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004527 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004528 }
4529 return skip;
4530}
4531
sfricke-samsungf692b972020-05-02 08:00:45 -07004532bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4533 VkDeviceSize countBufferOffset, bool khr) const {
4534 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004535 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004536 if (offset & 3) {
4537 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004538 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004539 }
4540
4541 if (countBufferOffset & 3) {
4542 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004543 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004544 countBufferOffset);
4545 }
4546 return skip;
4547}
4548
4549bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4550 VkDeviceSize offset, VkBuffer countBuffer,
4551 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4552 uint32_t stride) const {
4553 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4554}
4555
4556bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4557 VkDeviceSize offset, VkBuffer countBuffer,
4558 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4559 uint32_t stride) const {
4560 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4561}
4562
4563bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4564 VkDeviceSize countBufferOffset, bool khr) const {
4565 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004566 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004567 if (offset & 3) {
4568 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004569 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004570 }
4571
4572 if (countBufferOffset & 3) {
4573 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004574 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004575 countBufferOffset);
4576 }
4577 return skip;
4578}
4579
4580bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4581 VkDeviceSize offset, VkBuffer countBuffer,
4582 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4583 uint32_t stride) const {
4584 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4585}
4586
4587bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4588 VkDeviceSize offset, VkBuffer countBuffer,
4589 VkDeviceSize countBufferOffset,
4590 uint32_t maxDrawCount, uint32_t stride) const {
4591 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4592}
4593
Tony-LunarG4490de42021-06-21 15:49:19 -06004594bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4595 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4596 uint32_t firstInstance, uint32_t stride) const {
4597 bool skip = false;
4598 if (stride & 3) {
4599 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4600 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4601 }
4602 if (drawCount && nullptr == pVertexInfo) {
4603 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4604 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4605 "one or more valid instances of VkMultiDrawInfoEXT structures");
4606 }
4607 return skip;
4608}
4609
4610bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4611 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4612 uint32_t instanceCount, uint32_t firstInstance,
4613 uint32_t stride, const int32_t *pVertexOffset) const {
4614 bool skip = false;
4615 if (stride & 3) {
4616 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4617 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4618 }
4619 if (drawCount && nullptr == pIndexInfo) {
4620 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4621 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4622 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4623 }
4624 return skip;
4625}
4626
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004627bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4628 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004629 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004630 bool skip = false;
4631 for (uint32_t rect = 0; rect < rectCount; rect++) {
4632 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004633 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004634 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004635 }
sfricke-samsung10867682020-04-25 02:20:39 -07004636 if (pRects[rect].rect.extent.width == 0) {
4637 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004638 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004639 }
4640 if (pRects[rect].rect.extent.height == 0) {
4641 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004642 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004643 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004644 }
4645 return skip;
4646}
4647
Andrew Fobel3abeb992020-01-20 16:33:22 -05004648bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4649 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4650 VkImageFormatProperties2 *pImageFormatProperties,
4651 const char *apiName) const {
4652 bool skip = false;
4653
4654 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004655 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004656 if (image_stencil_struct != nullptr) {
4657 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4658 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4659 // No flags other than the legal attachment bits may be set
4660 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4661 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004662 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4663 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4664 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4665 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4666 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004667 }
4668 }
4669 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004670 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4671 if (image_drm_format) {
4672 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4673 skip |= LogError(
4674 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4675 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4676 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4677 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4678 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004679 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4680 skip |= LogError(
4681 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4682 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4683 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4684 apiName, image_drm_format->queueFamilyIndexCount);
4685 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004686 } else {
4687 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4688 skip |= LogError(
4689 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4690 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4691 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4692 apiName);
4693 }
4694 }
4695 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4696 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4697 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4698 if (!format_list || format_list->viewFormatCount == 0) {
4699 skip |= LogError(
4700 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4701 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4702 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4703 apiName);
4704 }
4705 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004706 }
4707
4708 return skip;
4709}
4710
4711bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4712 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4713 VkImageFormatProperties2 *pImageFormatProperties) const {
4714 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4715 "vkGetPhysicalDeviceImageFormatProperties2");
4716}
4717
4718bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4719 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4720 VkImageFormatProperties2 *pImageFormatProperties) const {
4721 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4722 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4723}
4724
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004725bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4726 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4727 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4728 bool skip = false;
4729
4730 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4731 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4732 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4733 }
4734
4735 return skip;
4736}
4737
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004738bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4739 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4740 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4741 bool skip = false;
4742
4743 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4744 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4745 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4746 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4747 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4748 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4749 }
4750
ziga-lunarg42f884b2021-08-25 16:13:20 +02004751 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004752}
4753
sfricke-samsung3999ef62020-02-09 17:05:59 -08004754bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4755 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4756 bool skip = false;
4757
4758 if (pRegions != nullptr) {
4759 for (uint32_t i = 0; i < regionCount; i++) {
4760 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004761 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004762 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004763 }
4764 }
4765 }
4766 return skip;
4767}
4768
Jeff Leger178b1e52020-10-05 12:22:23 -04004769bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4770 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4771 bool skip = false;
4772
4773 if (pCopyBufferInfo->pRegions != nullptr) {
4774 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4775 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06004776 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004777 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004778 }
4779 }
4780 }
4781 return skip;
4782}
4783
Tony-LunarGef035472021-11-02 10:23:33 -06004784bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
4785 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
4786 bool skip = false;
4787
4788 if (pCopyBufferInfo->pRegions != nullptr) {
4789 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4790 if (pCopyBufferInfo->pRegions[i].size == 0) {
4791 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
4792 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
4793 }
4794 }
4795 }
4796 return skip;
4797}
4798
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004799bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004800 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4801 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004802 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004803
4804 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004805 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4806 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4807 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004808 }
4809
4810 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004811 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4812 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4813 "), must be greater than zero and less than or equal to 65536.",
4814 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004815 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004816 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4817 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4818 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004819 }
4820 return skip;
4821}
4822
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004823bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004824 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004825 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004826
4827 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004828 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4829 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4830 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004831 }
4832
4833 if (size != VK_WHOLE_SIZE) {
4834 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004835 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004836 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4837 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004838 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004839 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4840 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004841 }
4842 }
4843 return skip;
4844}
4845
sfricke-samsunga1d00272021-03-10 21:37:41 -08004846bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004847 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004848
4849 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004850 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4851 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4852 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4853 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004854 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004855 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4856 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4857 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004858 }
4859
4860 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4861 // queueFamilyIndexCount uint32_t values
4862 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004863 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004864 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004865 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004866 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4867 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004868 }
4869 }
4870
Dave Houlton413a6782018-05-22 13:01:54 -06004871 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004872 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004873
sfricke-samsunga1d00272021-03-10 21:37:41 -08004874 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4875 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4876 if (format_list_info) {
4877 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4878 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4879 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4880 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004881 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
4882 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004883 func_name, viewFormatCount);
4884 }
4885
4886 // Using the first format, compare the rest of the formats against it that they are compatible
4887 for (uint32_t i = 1; i < viewFormatCount; i++) {
4888 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4889 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4890 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4891 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004892 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
4893 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004894 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4895 string_VkFormat(format_list_info->pViewFormats[i]));
4896 }
4897 }
4898 }
4899
4900 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4901 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4902 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4903 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4904 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4905 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4906 func_name);
4907 } else {
4908 if (format_list_info == nullptr) {
4909 skip |= LogError(
4910 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4911 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4912 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4913 func_name);
4914 } else if (format_list_info->viewFormatCount == 0) {
4915 skip |= LogError(
4916 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4917 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4918 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4919 func_name);
4920 } else {
4921 bool found_base_format = false;
4922 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4923 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4924 found_base_format = true;
4925 break;
4926 }
4927 }
4928 if (!found_base_format) {
4929 skip |=
4930 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4931 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4932 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4933 "pCreateInfo->imageFormat.",
4934 func_name);
4935 }
4936 }
4937 }
4938 }
4939 }
4940 return skip;
4941}
4942
4943bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4944 const VkAllocationCallbacks *pAllocator,
4945 VkSwapchainKHR *pSwapchain) const {
4946 bool skip = false;
4947 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4948 return skip;
4949}
4950
4951bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4952 const VkSwapchainCreateInfoKHR *pCreateInfos,
4953 const VkAllocationCallbacks *pAllocator,
4954 VkSwapchainKHR *pSwapchains) const {
4955 bool skip = false;
4956 if (pCreateInfos) {
4957 for (uint32_t i = 0; i < swapchainCount; i++) {
4958 std::stringstream func_name;
4959 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4960 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4961 }
4962 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004963 return skip;
4964}
4965
Jeff Bolz5c801d12019-10-09 10:38:45 -05004966bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004967 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004968
4969 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004970 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004971 if (present_regions) {
4972 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004973 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004974 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4975 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004976 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004977 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4978 "extension swapchainCount is %i. These values must be equal.",
4979 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004980 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004981 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004982 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4983 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004984 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4985 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4986 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004987 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004988 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004989 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004990 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004991 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004992 }
4993 }
4994
4995 return skip;
4996}
4997
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004998bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4999 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5000 const VkAllocationCallbacks *pAllocator,
5001 VkDisplayModeKHR *pMode) const {
5002 bool skip = false;
5003
5004 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5005 if (display_mode_parameters.visibleRegion.width == 0) {
5006 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5007 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5008 }
5009 if (display_mode_parameters.visibleRegion.height == 0) {
5010 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5011 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5012 }
5013 if (display_mode_parameters.refreshRate == 0) {
5014 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5015 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5016 }
5017
5018 return skip;
5019}
5020
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005021#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005022bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5023 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5024 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005025 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005026 bool skip = false;
5027
5028 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005029 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5030 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005031 }
5032
5033 return skip;
5034}
5035#endif // VK_USE_PLATFORM_WIN32_KHR
5036
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005037static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5038 bool partial_overlap = false;
5039
5040 static const std::vector<VkDescriptorType> all_descriptor_types = {
5041 VK_DESCRIPTOR_TYPE_SAMPLER,
5042 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5043 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5044 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5045 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5046 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5047 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5048 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5049 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5050 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5051 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5052 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5053 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5054 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5055 };
5056
5057 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5058 if (mutable_descriptor_type) {
5059 std::vector<VkDescriptorType> first_types, second_types;
5060 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5061 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5062 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5063 }
5064 } else {
5065 first_types = all_descriptor_types;
5066 }
5067 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5068 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5069 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5070 }
5071 } else {
5072 second_types = all_descriptor_types;
5073 }
5074
5075 bool complete_overlap = first_types.size() == second_types.size();
5076 bool disjoint = true;
5077 for (const auto first_type : first_types) {
5078 bool found = false;
5079 for (const auto second_type : second_types) {
5080 if (first_type == second_type) {
5081 found = true;
5082 break;
5083 }
5084 }
5085 if (found) {
5086 disjoint = false;
5087 } else {
5088 complete_overlap = false;
5089 }
5090 if (!disjoint && !complete_overlap) {
5091 partial_overlap = true;
5092 break;
5093 }
5094 }
5095 }
5096
5097 return partial_overlap;
5098}
5099
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005100bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005101 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005102 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005103 bool skip = false;
5104
5105 if (pCreateInfo) {
5106 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005107 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5108 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005109 }
5110
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005111 const auto *mutable_descriptor_type_features =
5112 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5113 bool mutable_descriptor_type_enabled =
5114 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5115
Petr Krausc8655be2017-09-27 18:56:51 +02005116 if (pCreateInfo->pPoolSizes) {
5117 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5118 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005119 skip |= LogError(
5120 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005121 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005122 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005123 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5124 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005125 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5126 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5127 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5128 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5129 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005130 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005131 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5132 skip |=
5133 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5134 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5135 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5136 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5137 i);
5138 }
5139 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5140 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5141 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5142 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5143 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5144 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5145 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5146 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5147 " and have sets which partially overlap.",
5148 i, j);
5149 }
5150 }
5151 }
5152 }
Petr Krausc8655be2017-09-27 18:56:51 +02005153 }
5154 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005155
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005156 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5157 skip |=
5158 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5159 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5160 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5161 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005162 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5163 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5164 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5165 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5166 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5167 }
Petr Krausc8655be2017-09-27 18:56:51 +02005168 }
5169
5170 return skip;
5171}
5172
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005173bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005174 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005175 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005176
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005177 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005178 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005179 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5180 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5181 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005182 }
5183
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005184 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005185 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005186 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5187 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5188 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005189 }
5190
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005191 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005192 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005193 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5194 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5195 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005196 }
5197
5198 return skip;
5199}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005200
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005201bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005202 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005203 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005204
5205 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005206 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5207 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005208 }
5209 return skip;
5210}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005211
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005212bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5213 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005214 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005215 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005216
5217 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005218 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005219 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005220 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5221 "vkCmdDispatch(): baseGroupX (%" PRIu32
5222 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5223 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005224 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005225 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5226 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5227 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5228 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005229 }
5230
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005231 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005232 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005233 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5234 "vkCmdDispatch(): baseGroupY (%" PRIu32
5235 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5236 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005237 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005238 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5239 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5240 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5241 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005242 }
5243
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005244 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005245 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005246 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5247 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5248 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5249 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005250 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005251 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5252 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5253 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5254 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005255 }
5256
5257 return skip;
5258}
5259
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005260bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5261 VkPipelineBindPoint pipelineBindPoint,
5262 VkPipelineLayout layout, uint32_t set,
5263 uint32_t descriptorWriteCount,
5264 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005265 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005266}
5267
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005268bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5269 uint32_t firstExclusiveScissor,
5270 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005271 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005272 bool skip = false;
5273
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005274 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005275 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005276 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005277 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5278 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5279 ") is not 0.",
5280 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005281 }
5282 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005283 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005284 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5285 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5286 ") is not 1.",
5287 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005288 }
5289 } else { // multiViewport enabled
5290 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005291 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005292 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5293 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5294 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5295 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005296 }
5297 }
5298
Jeff Bolz3e71f782018-08-29 23:15:45 -05005299 if (pExclusiveScissors) {
5300 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5301 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5302
5303 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005304 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5305 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5306 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005307 }
5308
5309 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005310 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5311 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5312 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005313 }
5314
5315 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5316 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005317 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5318 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5319 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5320 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005321 }
5322
5323 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5324 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005325 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5326 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5327 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5328 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005329 }
5330 }
5331 }
5332
5333 return skip;
5334}
5335
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005336bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5337 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005338 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005339 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005340 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5341 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5342 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5343 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5344 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5345 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005346 }
5347
5348 return skip;
5349}
5350
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005351bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5352 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005353 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005354 bool skip = false;
5355
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005356 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005357 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005358 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005359 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5360 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5361 ") is not 0.",
5362 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005363 }
5364 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005365 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005366 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5367 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5368 ") is not 1.",
5369 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005370 }
5371 }
5372
Jeff Bolz9af91c52018-09-01 21:53:57 -05005373 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005374 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005375 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5376 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5377 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5378 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005379 }
5380
5381 return skip;
5382}
5383
Jeff Bolz5c801d12019-10-09 10:38:45 -05005384bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5385 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5386 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005387 bool skip = false;
5388
Dave Houlton142c4cb2018-10-17 15:04:41 -06005389 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005390 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5391 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5392 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005393 }
5394
5395 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005396 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005397 }
5398
5399 return skip;
5400}
5401
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005402bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005403 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005404 bool skip = false;
5405
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005406 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005407 skip |= LogError(
5408 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005409 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5410 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005411 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005412 }
5413
5414 return skip;
5415}
5416
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005417bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5418 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005419 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005420 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005421 static const int condition_multiples = 0b0011;
5422 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005423 skip |= LogError(
5424 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005425 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005426 }
Lockee1c22882019-06-10 16:02:54 -06005427 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005428 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5429 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5430 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5431 stride);
Lockee1c22882019-06-10 16:02:54 -06005432 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005433 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005434 skip |= LogError(
5435 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005436 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5437 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005438 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005439 if (drawCount > device_limits.maxDrawIndirectCount) {
5440 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005441 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5442 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005443 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005444 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005445 return skip;
5446}
5447
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005448bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5449 VkDeviceSize offset, VkBuffer countBuffer,
5450 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005451 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005452 bool skip = false;
5453
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005454 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005455 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5456 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5457 "), is not a multiple of 4.",
5458 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005459 }
5460
5461 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005462 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5463 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5464 "), is not a multiple of 4.",
5465 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005466 }
5467
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005468 return skip;
5469}
5470
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005471bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005472 const VkAllocationCallbacks *pAllocator,
5473 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005474 bool skip = false;
5475
5476 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5477 if (pCreateInfo != nullptr) {
5478 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5479 // VkQueryPipelineStatisticFlagBits values
5480 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5481 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005482 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5483 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5484 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5485 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005486 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005487 if (pCreateInfo->queryCount == 0) {
5488 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5489 "vkCreateQueryPool(): queryCount must be greater than zero.");
5490 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005491 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005492 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005493}
5494
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005495bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5496 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005497 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005498 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5499 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005500}
5501
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005502void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005503 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5504 VkResult result) {
5505 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005506 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005507}
5508
Mike Schuchardt2df08912020-12-15 16:28:09 -08005509void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005510 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5511 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005512 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005513 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005514 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005515}
5516
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005517void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5518 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005519 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005520 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005521 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005522}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005523
Tony-LunarG3c287f62020-12-17 12:39:49 -07005524void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005525 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005526 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005527 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005528 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005529 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005530 }
5531 }
5532}
5533
5534void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005535 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005536 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005537 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5538 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5539 }
5540}
5541
5542void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005543 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005544 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005545 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5546 if (item->second == commandPool) {
5547 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005548 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005549 ++item;
5550 }
5551 }
5552}
5553
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005554bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005555 const VkAllocationCallbacks *pAllocator,
5556 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005557 bool skip = false;
5558
5559 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005560 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005561 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005562 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5563 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005564 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005565
5566 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005567 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005568 if (flags_info) {
5569 flags = flags_info->flags;
5570 }
5571
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005572 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005573 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005574 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005575 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5576 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005577 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005578 }
5579
5580#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005581 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005582#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005583 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5584 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005585#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005586 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005587#endif
5588
5589 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005590 skip |= LogError(
5591 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005592 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5593 }
5594 if (
5595#ifdef VK_USE_PLATFORM_WIN32_KHR
5596 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5597#endif
5598 (import_memory_fd && import_memory_fd->handleType) ||
5599#ifdef VK_USE_PLATFORM_ANDROID_KHR
5600 (import_memory_ahb && import_memory_ahb->buffer) ||
5601#endif
5602 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005603 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5604 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005605 }
5606 }
5607
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005608 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5609 if (export_memory) {
5610 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5611 if (export_memory_nv) {
5612 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5613 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5614 "VkExportMemoryAllocateInfoNV");
5615 }
5616#ifdef VK_USE_PLATFORM_WIN32_KHR
5617 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5618 if (export_memory_win32_nv) {
5619 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5620 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5621 "VkExportMemoryWin32HandleInfoNV");
5622 }
5623#endif
5624 }
5625
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005626 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005627 VkBool32 capture_replay = false;
5628 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005629 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005630 if (vulkan_12_features) {
5631 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5632 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5633 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005634 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005635 if (bda_features) {
5636 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5637 buffer_device_address = bda_features->bufferDeviceAddress;
5638 }
5639 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005640 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005641 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005642 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005643 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005644 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005645 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005646 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005647 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005648 }
5649 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005650 }
5651 return skip;
5652}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005653
Jason Macnak192fa0e2019-07-26 15:07:16 -07005654bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005655 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005656 bool skip = false;
5657
5658 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5659 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5660 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005661 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005662 } else {
5663 uint32_t vertex_component_size = 0;
5664 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5665 vertex_component_size = 4;
5666 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5667 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5668 vertex_component_size = 2;
5669 }
5670 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005671 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005672 }
5673 }
5674
5675 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5676 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005677 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005678 } else {
5679 uint32_t index_element_size = 0;
5680 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5681 index_element_size = 4;
5682 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5683 index_element_size = 2;
5684 }
5685 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005686 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005687 }
5688 }
5689 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5690 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005691 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005692 }
5693 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005694 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005695 }
5696 }
5697
5698 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005699 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005700 }
5701
5702 return skip;
5703}
5704
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005705bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5706 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005707 bool skip = false;
5708
5709 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005710 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005711 }
5712 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005713 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005714 }
5715
5716 return skip;
5717}
5718
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005719bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5720 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005721 bool skip = false;
5722 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005723 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005724 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005725 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005726 }
5727 return skip;
5728}
5729
5730bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005731 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005732 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005733 bool skip = false;
5734 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005735 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5736 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5737 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005738 }
5739 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005740 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5741 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5742 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005743 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005744 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5745 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5746 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5747 }
Jason Macnak5c954952019-07-09 15:46:12 -07005748 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5749 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005750 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5751 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5752 "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 -07005753 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005754 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005755 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005756 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5757 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005758 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5759 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005760 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005761 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005762 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5763 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5764 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005765 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005766 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005767 uint64_t total_triangle_count = 0;
5768 for (uint32_t i = 0; i < info.geometryCount; i++) {
5769 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005770
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005771 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005772
Jason Macnak5c954952019-07-09 15:46:12 -07005773 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5774 continue;
5775 }
5776 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5777 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005778 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005779 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5780 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5781 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005782 }
5783 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005784 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5785 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5786 for (uint32_t i = 1; i < info.geometryCount; i++) {
5787 const VkGeometryNV &geometry = info.pGeometries[i];
5788 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005789 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005790 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5791 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005792 "info.pGeometries[0].geometryType.",
5793 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005794 }
5795 }
5796 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005797 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5798 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5799 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5800 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5801 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5802 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5803 }
5804 }
5805 skip |=
5806 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005807 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005808 return skip;
5809}
5810
Ricardo Garciaa4935972019-02-21 17:43:18 +01005811bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5812 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005813 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005814 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005815 if (pCreateInfo) {
5816 if ((pCreateInfo->compactedSize != 0) &&
5817 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005818 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5819 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5820 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5821 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005822 }
Jason Macnak5c954952019-07-09 15:46:12 -07005823
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005824 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005825 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005826 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005827 return skip;
5828}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005829
Jeff Bolz5c801d12019-10-09 10:38:45 -05005830bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5831 const VkAccelerationStructureInfoNV *pInfo,
5832 VkBuffer instanceData, VkDeviceSize instanceOffset,
5833 VkBool32 update, VkAccelerationStructureNV dst,
5834 VkAccelerationStructureNV src, VkBuffer scratch,
5835 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005836 bool skip = false;
5837
5838 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005839 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005840 }
5841
5842 return skip;
5843}
5844
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005845bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5846 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5847 VkAccelerationStructureKHR *pAccelerationStructure) const {
5848 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005849 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005850 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005851 if (!acceleration_structure_features ||
5852 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5853 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5854 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5855 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005856 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005857 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5858 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005859 (acceleration_structure_features &&
5860 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005861 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005862 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5863 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5864 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5865 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005866 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005867 if (pCreateInfo->deviceAddress &&
5868 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5869 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5870 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5871 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5872 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005873 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5874 (acceleration_structure_features &&
5875 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5876 skip |= LogError(
5877 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5878 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5879 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5880 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005881 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5882 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005883 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5884 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005885 }
sourav parmar83c31b12020-05-06 12:30:54 -07005886 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005887 return skip;
5888}
5889
Jason Macnak5c954952019-07-09 15:46:12 -07005890bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5891 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005892 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005893 bool skip = false;
5894 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005895 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5896 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005897 }
5898 return skip;
5899}
5900
sourav parmarcd5fb182020-07-17 12:58:44 -07005901bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5902 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5903 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5904 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005905 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005906 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005907 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005908 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005909 }
5910 return skip;
5911}
5912
Peter Chen85366392019-05-14 15:20:11 -04005913bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5914 uint32_t createInfoCount,
5915 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5916 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005917 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005918 bool skip = false;
5919
5920 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005921 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5922 std::stringstream msg;
5923 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5924 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5925 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005926 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005927 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005928 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005929 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5930 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5931 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5932 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005933 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005934
5935 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005936 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005937 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5938 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5939 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5940 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5941 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5942 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5943 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5944 }
5945 }
5946
sourav parmarf4a78252020-04-10 13:04:21 -07005947 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5948 skip |=
5949 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5950 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5951 }
5952 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5953 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5954 skip |=
5955 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5956 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5957 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5958 }
5959 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5960 if (pCreateInfos[i].basePipelineIndex != -1) {
5961 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5962 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5963 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5964 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5965 "and pCreateInfos->basePipelineIndex is not -1.");
5966 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005967 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005968 skip |=
5969 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5970 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5971 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5972 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5973 "that element.");
5974 }
sourav parmarf4a78252020-04-10 13:04:21 -07005975 }
5976 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005977 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005978 skip |=
5979 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5980 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5981 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5982 "commands pCreateInfos parameter.");
5983 }
5984 } else {
5985 if (pCreateInfos[i].basePipelineIndex != -1) {
5986 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5987 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5988 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5989 }
5990 }
5991 }
5992 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5993 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5994 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5995 }
5996 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5997 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5998 "vkCreateRayTracingPipelinesNV: flags must not include "
5999 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6000 }
6001 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6002 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6003 "vkCreateRayTracingPipelinesNV: flags must not include "
6004 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6005 }
6006 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6007 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6008 "vkCreateRayTracingPipelinesNV: flags must not include "
6009 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6010 }
6011 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6012 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6013 "vkCreateRayTracingPipelinesNV: flags must not include "
6014 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6015 }
6016 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6017 skip |= LogError(
6018 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6019 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6020 }
6021 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6022 skip |= LogError(
6023 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6024 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6025 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006026 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6027 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6028 "vkCreateRayTracingPipelinesNV: flags must not include "
6029 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6030 }
6031 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6032 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6033 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6034 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006035 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6036 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6037 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6038 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6039 }
Peter Chen85366392019-05-14 15:20:11 -04006040 }
6041
6042 return skip;
6043}
6044
sourav parmarcd5fb182020-07-17 12:58:44 -07006045bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6046 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6047 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006048 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006049 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006050 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6051 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6052 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006053 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006054 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006055 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6056 std::stringstream msg;
6057 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6058 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
6059 &pCreateInfos[i].pStages[i]);
6060 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006061 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6062 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6063 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6064 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6065 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6066 }
6067 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6068 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6069 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6070 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6071 }
6072 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006073 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006074 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
6075 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07006076 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6077 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6078 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006079 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6080 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6081 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006082 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-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006088 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006089 "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 }
sourav parmarf4a78252020-04-10 13:04:21 -07006093 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006094 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6095 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006096 }
6097 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006098 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006099 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006100 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6101 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006102 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006103 }
6104 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6105 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6106 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006107 }
6108 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6109 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6110 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6111 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6112 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6113 skip |= LogError(
6114 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006115 "vkCreateRayTracingPipelinesKHR: If flags includes "
6116 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006117 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6118 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6119 "must not be VK_SHADER_UNUSED_KHR");
6120 }
6121 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6122 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6123 skip |= LogError(
6124 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006125 "vkCreateRayTracingPipelinesKHR: If flags includes "
6126 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006127 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6128 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6129 "element must not be VK_SHADER_UNUSED_KHR");
6130 }
6131 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006132 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6133 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6134 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6135 skip |= LogError(
6136 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6137 "vkCreateRayTracingPipelinesKHR: If "
6138 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6139 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6140 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6141 }
6142 }
sourav parmarf4a78252020-04-10 13:04:21 -07006143 }
6144 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6145 if (pCreateInfos[i].basePipelineIndex != -1) {
6146 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6147 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006148 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006149 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6150 "and pCreateInfos->basePipelineIndex is not -1.");
6151 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006152 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006153 skip |=
6154 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6155 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6156 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6157 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6158 "element.");
6159 }
sourav parmarf4a78252020-04-10 13:04:21 -07006160 }
6161 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006162 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006163 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006164 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006165 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6166 ") must be a valid into the calling"
6167 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006168 pCreateInfos[i].basePipelineIndex, createInfoCount);
6169 }
6170 } else {
6171 if (pCreateInfos[i].basePipelineIndex != -1) {
6172 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006173 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006174 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6175 }
6176 }
6177 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006178 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6179 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6180 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6181 "vkCreateRayTracingPipelinesKHR: If flags includes "
6182 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6183 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006184 }
6185 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6186 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6187 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6188 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6189 "pLibraryInfo and pLibraryInterface must be NULL.");
6190 }
6191 if (pCreateInfos[i].pLibraryInfo) {
6192 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6193 if (pCreateInfos[i].stageCount == 0) {
6194 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6195 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6196 "stageCount must not be 0.");
6197 }
6198 if (pCreateInfos[i].groupCount == 0) {
6199 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6200 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6201 "groupCount must not be 0.");
6202 }
6203 } else {
6204 if (pCreateInfos[i].pLibraryInterface == NULL) {
6205 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6206 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6207 "is greater than 0, its "
6208 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006209 }
6210 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006211 }
6212 if (pCreateInfos[i].pLibraryInterface) {
6213 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6214 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6215 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6216 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6217 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6218 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006219 }
6220 if (deferredOperation != VK_NULL_HANDLE) {
6221 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6222 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6223 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6224 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006225 }
6226 }
ziga-lunargdea76582021-09-17 14:38:08 +02006227 if (pCreateInfos[i].pDynamicState) {
6228 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6229 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6230 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6231 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6232 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6233 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6234 }
6235 }
6236 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006237 }
6238
6239 return skip;
6240}
6241
Mike Schuchardt21638df2019-03-16 10:52:02 -07006242#ifdef VK_USE_PLATFORM_WIN32_KHR
6243bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6244 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006245 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006246 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006247 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006248 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006249 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006250 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006251 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006252 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006253 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006254 skip |=
6255 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006256 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006257 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6258 skip |= validate_struct_type(
6259 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6260 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6261 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6262 if (pSurfaceInfo != NULL) {
6263 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6264 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6265 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6266
6267 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6268 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6269 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6270 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006271 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6272 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006273
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006274 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6275 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6276 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6277 "VK_GOOGLE_surfaceless_query is not enabled.");
6278 }
6279
Mike Schuchardt21638df2019-03-16 10:52:02 -07006280 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6281 }
6282 return skip;
6283}
6284#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006285
6286bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6287 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006288 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006289 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6290 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006291 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006292 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6293 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6294 }
6295 return skip;
6296}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006297
6298bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006299 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006300 bool skip = false;
6301
6302 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006303 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006304 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006305 }
6306
6307 return skip;
6308}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006309
6310bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006311 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006312 bool skip = false;
6313
6314 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006315 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6316 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006317 }
6318
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006319 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006320 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006321 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6322 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006323 }
6324
6325 return skip;
6326}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006327
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006328bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6329 uint32_t bindingCount, const VkBuffer *pBuffers,
6330 const VkDeviceSize *pOffsets) const {
6331 bool skip = false;
6332 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006333 skip |=
6334 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6335 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6336 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006337 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6338 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006339 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6340 ") must be less than "
6341 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006342 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6343 }
6344
Jeff Bolz165818a2020-05-08 11:19:03 -05006345 for (uint32_t i = 0; i < bindingCount; ++i) {
6346 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006347 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006348 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006349 skip |=
6350 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6351 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006352 } else {
6353 if (pOffsets[i] != 0) {
6354 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006355 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6356 "] is not 0",
6357 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006358 }
6359 }
6360 }
6361 }
6362
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006363 return skip;
6364}
6365
Mark Lobodzinski84988402019-09-11 15:27:30 -06006366bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006367 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006368 bool skip = false;
6369 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006370 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6371 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006372 }
6373 return skip;
6374}
6375
6376bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006377 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006378 bool skip = false;
6379 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006380 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6381 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006382 }
6383 return skip;
6384}
Petr Kraus3d720392019-11-13 02:52:39 +01006385
6386bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6387 VkSemaphore semaphore, VkFence fence,
6388 uint32_t *pImageIndex) const {
6389 bool skip = false;
6390
6391 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006392 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6393 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006394 }
6395
6396 return skip;
6397}
6398
6399bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6400 uint32_t *pImageIndex) const {
6401 bool skip = false;
6402
6403 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006404 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6405 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006406 }
6407
6408 return skip;
6409}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006410
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006411bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6412 uint32_t firstBinding, uint32_t bindingCount,
6413 const VkBuffer *pBuffers,
6414 const VkDeviceSize *pOffsets,
6415 const VkDeviceSize *pSizes) const {
6416 bool skip = false;
6417
6418 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6419 for (uint32_t i = 0; i < bindingCount; ++i) {
6420 if (pOffsets[i] & 3) {
6421 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6422 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6423 }
6424 }
6425
6426 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6427 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6428 "%s: The firstBinding(%" PRIu32
6429 ") index is greater than or equal to "
6430 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6431 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6432 }
6433
6434 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6435 skip |=
6436 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6437 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6438 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6439 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6440 }
6441
6442 for (uint32_t i = 0; i < bindingCount; ++i) {
6443 // pSizes is optional and may be nullptr.
6444 if (pSizes != nullptr) {
6445 if (pSizes[i] != VK_WHOLE_SIZE &&
6446 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6447 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6448 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6449 ") is not VK_WHOLE_SIZE and is greater than "
6450 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6451 cmd_name, i, pSizes[i]);
6452 }
6453 }
6454 }
6455
6456 return skip;
6457}
6458
6459bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6460 uint32_t firstCounterBuffer,
6461 uint32_t counterBufferCount,
6462 const VkBuffer *pCounterBuffers,
6463 const VkDeviceSize *pCounterBufferOffsets) const {
6464 bool skip = false;
6465
6466 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6467 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6468 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6469 "%s: The firstCounterBuffer(%" PRIu32
6470 ") index is greater than or equal to "
6471 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6472 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6473 }
6474
6475 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6476 skip |=
6477 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6478 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6479 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6480 cmd_name, firstCounterBuffer, counterBufferCount,
6481 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6482 }
6483
6484 return skip;
6485}
6486
6487bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6488 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6489 const VkBuffer *pCounterBuffers,
6490 const VkDeviceSize *pCounterBufferOffsets) const {
6491 bool skip = false;
6492
6493 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6494 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6495 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6496 "%s: The firstCounterBuffer(%" PRIu32
6497 ") index is greater than or equal to "
6498 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6499 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6500 }
6501
6502 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6503 skip |=
6504 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6505 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6506 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6507 cmd_name, firstCounterBuffer, counterBufferCount,
6508 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6509 }
6510
6511 return skip;
6512}
6513
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006514bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6515 uint32_t firstInstance, VkBuffer counterBuffer,
6516 VkDeviceSize counterBufferOffset,
6517 uint32_t counterOffset, uint32_t vertexStride) const {
6518 bool skip = false;
6519
6520 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006521 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6522 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6523 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6524 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006525 }
6526
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006527 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006528 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006529 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006530 }
6531
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006532 return skip;
6533}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006534
6535bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6536 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6537 const VkAllocationCallbacks *pAllocator,
6538 VkSamplerYcbcrConversion *pYcbcrConversion,
6539 const char *apiName) const {
6540 bool skip = false;
6541
6542 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006543 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006544 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006545 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006546 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6547 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006548 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006549 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006550 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006551
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006552#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006553 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006554 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006555#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006556 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006557#endif
6558
sfricke-samsung1a72f942020-07-25 12:09:18 -07006559 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006560
6561 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006562 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006563 const VkComponentMapping components = pCreateInfo->components;
6564 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6565 if (FormatIsXChromaSubsampled(format) == true) {
6566 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6567 skip |=
6568 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006569 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6570 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006571 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006572 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006573
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006574 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6575 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6576 skip |= LogError(
6577 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6578 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6579 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6580 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6581 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006582
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006583 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6584 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6585 skip |=
6586 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006587 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6588 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006589 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006590 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006591
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006592 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6593 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6594 skip |=
6595 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006596 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6597 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006598 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006599 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006600
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006601 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006602 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6603 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6604 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006605 skip |=
6606 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006607 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6608 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006609 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6610 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006611 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006612 }
6613
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006614 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6615 // Checks same VU multiple ways in order to give a more useful error message
6616 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6617 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6618 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6619 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6620 skip |= LogError(
6621 device, vuid,
6622 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6623 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6624 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6625 string_VkComponentSwizzle(components.b));
6626 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006627
sfricke-samsunged028b02021-09-06 23:14:51 -07006628 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6629 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006630 // 3 = no [a]
6631 // 2 = no [b,a]
6632 // 1 = no [g,b,a]
6633 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006634 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006635
sfricke-samsunged028b02021-09-06 23:14:51 -07006636 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6637 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006638 skip |= LogError(device, vuid,
6639 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6640 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6641 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6642 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006643 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006644 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6645 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6646 skip |= LogError(device, vuid,
6647 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6648 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6649 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6650 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6651 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006652 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006653 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6654 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6655 skip |= LogError(device, vuid,
6656 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6657 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6658 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6659 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6660 string_VkComponentSwizzle(components.b));
6661 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006662 }
6663 }
6664
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006665 return skip;
6666}
6667
6668bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6669 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6670 const VkAllocationCallbacks *pAllocator,
6671 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6672 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6673 "vkCreateSamplerYcbcrConversion");
6674}
6675
6676bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6677 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6678 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6679 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6680 "vkCreateSamplerYcbcrConversionKHR");
6681}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006682
6683bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6684 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6685 bool skip = false;
6686 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6687 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6688
6689 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006690 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6691 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6692 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6693 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6694 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006695 }
6696 return skip;
6697}
sourav parmara96ab1a2020-04-25 16:28:23 -07006698
6699bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006700 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006701 bool skip = false;
6702 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6703 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6704 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6705 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006706 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006707 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6708 skip |= LogError(
6709 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6710 "vkCopyAccelerationStructureToMemoryKHR: The "
6711 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6712 }
6713 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6714 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6715 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6716 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6717 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6718 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006719 return skip;
6720}
6721
6722bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6723 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6724 bool skip = false;
6725 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6726 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6727 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6728 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6729 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006730 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6731 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006732 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006733 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006734 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006735 return skip;
6736}
6737
6738bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6739 const char *api_name) const {
6740 bool skip = false;
6741 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6742 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6743 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6744 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6745 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6746 api_name);
6747 }
6748 return skip;
6749}
6750
6751bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006752 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006753 bool skip = false;
6754 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006755 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006756 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006757 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006758 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6759 "vkCopyAccelerationStructureKHR: The "
6760 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006761 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006762 return skip;
6763}
6764
6765bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6766 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6767 bool skip = false;
6768 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6769 return skip;
6770}
6771
6772bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006773 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006774 bool skip = false;
6775 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006776 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006777 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6778 }
6779 return skip;
6780}
6781
6782bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006783 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006784 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006785 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006786 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006787 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6788 skip |= LogError(
6789 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6790 "vkCopyMemoryToAccelerationStructureKHR: The "
6791 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006792 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006793 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6794 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006795 return skip;
6796}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006797
sourav parmara96ab1a2020-04-25 16:28:23 -07006798bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6799 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6800 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006801 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006802 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6803 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006804 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006805 pInfo->src.deviceAddress);
6806 }
sourav parmar83c31b12020-05-06 12:30:54 -07006807 return skip;
6808}
6809bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6810 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6811 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6812 bool skip = false;
6813 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6814 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6815 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6816 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6817 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6818 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6819 }
6820 return skip;
6821}
6822bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6823 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6824 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6825 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006826 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006827 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6828 skip |= LogError(
6829 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6830 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6831 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6832 }
sourav parmar83c31b12020-05-06 12:30:54 -07006833 if (dataSize < accelerationStructureCount * stride) {
6834 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6835 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006836 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006837 dataSize, accelerationStructureCount, stride);
6838 }
6839 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6840 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6841 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6842 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6843 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6844 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6845 }
6846 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6847 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6848 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6849 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6850 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6851 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6852 stride);
6853 }
6854 }
6855 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6856 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6857 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6858 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6859 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6860 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6861 stride);
6862 }
6863 }
sourav parmar83c31b12020-05-06 12:30:54 -07006864 return skip;
6865}
6866bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6867 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6868 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006869 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006870 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6871 skip |= LogError(
6872 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6873 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6874 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006875 }
6876 return skip;
6877}
6878
6879bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006880 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6881 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6882 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6883 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006884 uint32_t width, uint32_t height, uint32_t depth) const {
6885 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006886 // RayGen
6887 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6888 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6889 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006890 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006891 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6892 0) {
6893 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6894 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6895 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6896 }
6897 // Callable
6898 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6899 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6900 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6901 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006902 }
6903 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6904 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6905 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006906 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6907 }
6908 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6909 0) {
6910 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6911 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6912 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006913 }
6914 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006915 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6916 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6917 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6918 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006919 }
6920 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6921 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006922 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6923 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006924 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006925 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6926 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6927 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6928 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6929 }
sourav parmar83c31b12020-05-06 12:30:54 -07006930 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006931 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6932 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6933 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6934 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006935 }
6936 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6937 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6938 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006939 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6940 }
6941 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6942 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6943 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6944 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6945 }
6946 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6947 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6948 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6949 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6950 }
6951 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6952 skip |=
6953 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6954 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6955 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006956 }
6957
sourav parmarcd5fb182020-07-17 12:58:44 -07006958 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6959 skip |=
6960 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6961 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6962 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6963 }
6964
6965 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6966 skip |=
6967 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6968 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6969 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006970 }
6971 return skip;
6972}
6973
sourav parmarcd5fb182020-07-17 12:58:44 -07006974bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6975 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6976 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6977 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006978 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006979 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006980 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6981 skip |= LogError(
6982 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6983 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6984 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006985 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006986 // RayGen
6987 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6988 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6989 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006990 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006991 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6992 0) {
6993 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6994 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6995 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6996 }
6997 // Callabe
6998 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6999 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7000 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7001 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007002 }
7003 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7004 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007005 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7006 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7007 }
7008 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7009 0) {
7010 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7011 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7012 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007013 }
7014 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007015 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7016 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7017 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7018 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007019 }
7020 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7021 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007022 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7023 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007024 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007025 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7026 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7027 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7028 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7029 }
sourav parmar83c31b12020-05-06 12:30:54 -07007030 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007031 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7032 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7033 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7034 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007035 }
7036 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7037 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007038 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7039 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7040 }
7041 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7042 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7043 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7044 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007045 }
7046
sourav parmarcd5fb182020-07-17 12:58:44 -07007047 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7048 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7049 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007050 }
7051 return skip;
7052}
7053bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7054 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7055 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7056 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7057 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7058 uint32_t width, uint32_t height, uint32_t depth) const {
7059 bool skip = false;
7060 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7061 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7062 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7063 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7064 }
7065 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7066 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7067 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7068 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7069 }
7070 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7071 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7072 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7073 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7074 }
7075
7076 // hitShader
7077 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7078 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7079 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7080 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7081 }
7082 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7083 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7084 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7085 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7086 }
7087 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7088 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7089 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7090 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7091 }
7092
7093 // missShader
7094 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7095 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7096 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7097 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7098 }
7099 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7100 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7101 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7102 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7103 }
7104 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7105 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7106 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7107 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7108 }
7109
7110 // raygenShader
7111 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7112 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7113 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007114 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7115 }
7116 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7117 skip |=
7118 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7119 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7120 }
7121 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7122 skip |=
7123 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7124 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7125 }
7126 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7127 skip |=
7128 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7129 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007130 }
7131 return skip;
7132}
7133
sourav parmar83c31b12020-05-06 12:30:54 -07007134bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007135 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7136 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007137 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007138 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7139 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007140 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7141 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007142 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007143 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7144 }
7145 return skip;
7146}
7147
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007148bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7149 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007150 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007151 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007152
7153 if (!physical_device_features.multiViewport) {
7154 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007155 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7156 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007157 viewportCount);
7158 }
7159 } else { // multiViewport enabled
7160 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007161 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7162 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007163 ") must "
7164 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007165 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007166 }
7167 }
7168
7169 if (pViewports) {
7170 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7171 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007172 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007173 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007174 }
7175 }
7176
7177 return skip;
7178}
7179
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007180bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7181 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007182 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007183 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7184 return skip;
7185}
7186
7187bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7188 const VkViewport *pViewports) const {
7189 bool skip = false;
7190 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7191 return skip;
7192}
7193
7194bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7195 const VkRect2D *pScissors, bool is_ext) const {
7196 bool skip = false;
7197 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007198
7199 if (!physical_device_features.multiViewport) {
7200 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007201 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7202 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007203 ") must "
7204 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007205 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007206 }
7207 } else { // multiViewport enabled
7208 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007209 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7210 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007211 ") must "
7212 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007213 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007214 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007215 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7216 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007217 ") must "
7218 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007219 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007220 }
7221 }
7222
7223 if (pScissors) {
7224 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7225 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7226
7227 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007228 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7229 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007230 }
7231
7232 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007233 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7234 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007235 }
7236
7237 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7238 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007239 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7240 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7241 "] will overflow int32_t.",
7242 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007243 }
7244
7245 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7246 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007247 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7248 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7249 "] will overflow int32_t.",
7250 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7251 }
7252 }
7253 }
7254
7255 return skip;
7256}
7257
7258bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7259 const VkRect2D *pScissors) const {
7260 bool skip = false;
7261 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7262 return skip;
7263}
7264
7265bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7266 const VkRect2D *pScissors) const {
7267 bool skip = false;
7268 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7269 return skip;
7270}
7271
7272bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7273 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7274 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7275 bool is_2ext) const {
7276 bool skip = false;
7277 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7278 if (firstBinding >= device_limits.maxVertexInputBindings) {
7279 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7280 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7281 firstBinding, device_limits.maxVertexInputBindings);
7282 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7283 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7284 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7285 ") must be less than "
7286 "maxVertexInputBindings (%" PRIu32 ")",
7287 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7288 }
7289
7290 for (uint32_t i = 0; i < bindingCount; ++i) {
7291 if (pBuffers[i] == VK_NULL_HANDLE) {
7292 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7293 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7294 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7295 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7296 } else {
7297 if (pOffsets[i] != 0) {
7298 skip |=
7299 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7300 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7301 }
7302 }
7303 }
7304 if (pStrides) {
7305 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7306 skip |=
7307 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7308 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7309 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007310 }
7311 }
7312 }
7313
7314 return skip;
7315}
7316
7317bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7318 uint32_t bindingCount, const VkBuffer *pBuffers,
7319 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7320 const VkDeviceSize *pStrides) const {
7321 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007322 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7323 return skip;
7324}
Piers Daniell39842ee2020-07-10 16:42:33 -06007325
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007326bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7327 uint32_t bindingCount, const VkBuffer *pBuffers,
7328 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7329 const VkDeviceSize *pStrides) const {
7330 bool skip = false;
7331 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007332 return skip;
7333}
sourav parmarcd5fb182020-07-17 12:58:44 -07007334
7335bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7336 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7337 bool skip = false;
7338 for (uint32_t i = 0; i < infoCount; ++i) {
7339 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7340 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7341 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7342 }
7343 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7344 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7345 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7346 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7347 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7348 api_name);
7349 }
7350 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7351 skip |=
7352 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7353 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7354 }
7355 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7356 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7357 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7358 }
7359 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7360 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7361 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7362 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7363 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7364 api_name);
7365 }
7366 if (pInfos[i].pGeometries) {
7367 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7368 skip |= validate_ranged_enum(
7369 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7370 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7371 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7372 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007373 skip |= validate_struct_type(
7374 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7375 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7376 &(pInfos[i].pGeometries[j].geometry.triangles),
7377 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7378 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7379 skip |= validate_struct_pnext(
7380 api_name,
7381 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7382 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7383 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7384 skip |=
7385 validate_ranged_enum(api_name,
7386 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7387 ParameterName::IndexVector{i, j}),
7388 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7389 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7390 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7391 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7392 &pInfos[i].pGeometries[j].geometry.triangles,
7393 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7394 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7395 skip |= validate_ranged_enum(
7396 api_name,
7397 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7398 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7399 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7400
7401 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7402 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7403 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7404 }
7405 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7406 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7407 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7408 skip |=
7409 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7410 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7411 api_name);
7412 }
7413 }
7414 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7415 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7416 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7417 &pInfos[i].pGeometries[j].geometry.instances,
7418 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7419 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7420 skip |= validate_struct_type(
7421 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7422 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7423 &(pInfos[i].pGeometries[j].geometry.instances),
7424 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7425 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7426 skip |= validate_struct_pnext(
7427 api_name,
7428 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7429 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7430 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7431
7432 skip |= validate_bool32(api_name,
7433 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7434 ParameterName::IndexVector{i, j}),
7435 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7436 }
7437 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7438 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7439 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7440 &pInfos[i].pGeometries[j].geometry.aabbs,
7441 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7442 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7443 skip |= validate_struct_type(
7444 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7445 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7446 &(pInfos[i].pGeometries[j].geometry.aabbs),
7447 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7448 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7449 skip |= validate_struct_pnext(
7450 api_name,
7451 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7452 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7453 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7454 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7455 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7456 "(%s):stride must be less than or equal to 2^32-1", api_name);
7457 }
7458 }
7459 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7460 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7461 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7462 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7463 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7464 api_name);
7465 }
7466 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7467 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7468 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7469 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7470 "of elements of"
7471 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7472 api_name);
7473 }
7474 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7475 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7476 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7477 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7478 api_name);
7479 }
7480 }
7481 }
7482 }
7483 if (pInfos[i].ppGeometries != NULL) {
7484 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7485 skip |= validate_ranged_enum(
7486 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7487 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7488 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7489 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007490 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7491 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7492 &pInfos[i].ppGeometries[j]->geometry.triangles,
7493 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7494 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7495 skip |= validate_struct_type(
7496 api_name,
7497 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7498 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7499 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7500 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7501 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7502 skip |= validate_struct_pnext(
7503 api_name,
7504 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7505 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7506 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7507 skip |= validate_ranged_enum(api_name,
7508 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7509 ParameterName::IndexVector{i, j}),
7510 "VkFormat", AllVkFormatEnums,
7511 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7512 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7513 skip |= validate_ranged_enum(api_name,
7514 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7515 ParameterName::IndexVector{i, j}),
7516 "VkIndexType", AllVkIndexTypeEnums,
7517 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7518 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7519 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7520 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7521 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7522 }
7523 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7524 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7525 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7526 skip |=
7527 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7528 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7529 api_name);
7530 }
7531 }
7532 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7533 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7534 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7535 &pInfos[i].ppGeometries[j]->geometry.instances,
7536 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7537 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7538 skip |= validate_struct_type(
7539 api_name,
7540 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7541 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7542 &(pInfos[i].ppGeometries[j]->geometry.instances),
7543 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7544 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7545 skip |= validate_struct_pnext(
7546 api_name,
7547 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7548 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7549 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7550 skip |= validate_bool32(api_name,
7551 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7552 ParameterName::IndexVector{i, j}),
7553 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7554 }
7555 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7556 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7557 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7558 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7559 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7560 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7561 skip |= validate_struct_type(
7562 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7563 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7564 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7565 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7566 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7567 skip |= validate_struct_pnext(
7568 api_name,
7569 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7570 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7571 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7572 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7573 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7574 "(%s):stride must be less than or equal to 2^32-1", api_name);
7575 }
7576 }
7577 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7578 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7579 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7580 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7581 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7582 api_name);
7583 }
7584 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7585 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7586 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7587 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7588 "of elements of"
7589 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7590 api_name);
7591 }
7592 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7593 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7594 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7595 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7596 api_name);
7597 }
7598 }
7599 }
7600 }
7601 }
7602 return skip;
7603}
7604bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7605 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7606 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7607 bool skip = false;
7608 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7609 for (uint32_t i = 0; i < infoCount; ++i) {
7610 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7611 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7612 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7613 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7614 "scratchData.deviceAddress member must be a multiple of "
7615 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7616 }
7617 for (uint32_t k = 0; k < infoCount; ++k) {
7618 if (i == k) continue;
7619 bool found = false;
7620 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007621 skip |=
7622 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7623 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7624 ") of pInfos must "
7625 "not be "
7626 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7627 ") of pInfos.",
7628 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007629 found = true;
7630 }
7631 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007632 skip |=
7633 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7634 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7635 ") of pInfos must "
7636 "not be "
7637 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7638 ") of pInfos.",
7639 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007640 found = true;
7641 }
7642 if (found) break;
7643 }
7644 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7645 if (pInfos[i].pGeometries) {
7646 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7647 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7648 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7649 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7650 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7651 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7652 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7653 }
7654 } else {
7655 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7656 skip |=
7657 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7658 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7659 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7660 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7661 }
7662 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007663 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007664 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7665 skip |= LogError(
7666 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7667 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7668 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7669 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007670 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7671 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007672 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7673 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7674 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7675 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7676 }
7677 }
7678 } else if (pInfos[i].ppGeometries) {
7679 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7680 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7681 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7682 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7683 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7684 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7685 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7686 }
7687 } else {
7688 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7689 skip |=
7690 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7691 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7692 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7693 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7694 }
7695 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007696 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007697 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7698 skip |= LogError(
7699 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7700 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7701 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7702 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007703 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7704 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007705 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7706 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7707 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7708 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7709 }
7710 }
7711 }
7712 }
7713 }
7714 return skip;
7715}
7716
7717bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7718 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7719 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7720 const uint32_t *const *ppMaxPrimitiveCounts) const {
7721 bool skip = false;
7722 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7723 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007724 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007725 if (!ray_tracing_acceleration_structure_features ||
7726 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7727 skip |= LogError(
7728 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7729 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7730 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7731 }
7732 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007733 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7734 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7735 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7736 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7737 "scratchData.deviceAddress member must be a multiple of "
7738 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7739 }
7740 for (uint32_t k = 0; k < infoCount; ++k) {
7741 if (i == k) continue;
7742 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007743 skip |= LogError(
7744 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7745 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7746 ") "
7747 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7748 "any other element [%" PRIu32 ") of pInfos.",
7749 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007750 break;
7751 }
7752 }
7753 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7754 if (pInfos[i].pGeometries) {
7755 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7756 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7757 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7758 skip |= LogError(
7759 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7760 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7761 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7762 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7763 }
7764 } else {
7765 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7766 skip |= LogError(
7767 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7768 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7769 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7770 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7771 }
7772 }
7773 }
7774 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7775 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7776 skip |= LogError(
7777 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7778 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7779 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7780 }
7781 }
7782 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7783 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7784 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7785 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7786 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7787 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7788 }
7789 }
7790 } else if (pInfos[i].ppGeometries) {
7791 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7792 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7793 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7794 skip |= LogError(
7795 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7796 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7797 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7798 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7799 }
7800 } else {
7801 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7802 skip |= LogError(
7803 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7804 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7805 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7806 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7807 }
7808 }
7809 }
7810 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7811 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7812 skip |= LogError(
7813 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7814 "vkCmdBuildAccelerationStructuresIndirectKHR: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 }
7817 }
7818 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7819 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7820 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7821 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7822 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7823 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7824 }
7825 }
7826 }
7827 }
7828 }
7829 return skip;
7830}
7831
7832bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7833 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7834 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7835 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7836 bool skip = false;
7837 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7838 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007839 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007840 if (!ray_tracing_acceleration_structure_features ||
7841 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7842 skip |=
7843 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7844 "vkBuildAccelerationStructuresKHR: The "
7845 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7846 }
7847 for (uint32_t i = 0; i < infoCount; ++i) {
7848 for (uint32_t j = 0; j < infoCount; ++j) {
7849 if (i == j) continue;
7850 bool found = false;
7851 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007852 skip |=
7853 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7854 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
7855 ") of pInfos must "
7856 "not be "
7857 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7858 ") of pInfos.",
7859 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007860 found = true;
7861 }
7862 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007863 skip |=
7864 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7865 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
7866 ") of pInfos must "
7867 "not be "
7868 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7869 ") of pInfos.",
7870 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007871 found = true;
7872 }
7873 if (found) break;
7874 }
7875 }
7876 return skip;
7877}
7878
7879bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7880 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7881 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7882 bool skip = false;
7883 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7884 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007885 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7886 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007887 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7888 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7889 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7890 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01007891 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
7892 }
7893 if (pBuildInfo != nullptr) {
7894 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
7895 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
7896 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
7897 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
7898 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007899 }
7900 return skip;
7901}
sfricke-samsungecafb192021-01-17 08:21:14 -08007902
7903bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7904 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7905 const VkAllocationCallbacks *pAllocator,
7906 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7907 bool skip = false;
7908 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7909 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7910 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7911 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7912 }
7913 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007914}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007915
7916bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7917 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7918 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7919 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7920 bool skip = false;
7921 const auto *vertex_input_dynamic_state_features =
7922 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7923 const auto *vertex_attribute_divisor_features =
7924 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7925
7926 // VUID-vkCmdSetVertexInputEXT-None-04790
7927 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7928 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7929 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7930 }
7931
7932 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7933 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7934 skip |=
7935 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7936 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7937 }
7938
7939 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7940 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7941 skip |= LogError(
7942 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7943 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7944 }
7945
7946 // VUID-vkCmdSetVertexInputEXT-binding-04793
7947 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7948 bool binding_found = false;
7949 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7950 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7951 binding_found = true;
7952 break;
7953 }
7954 }
7955 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007956 skip |= LogError(
7957 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7958 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007959 }
7960 }
7961
7962 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7963 if (vertexBindingDescriptionCount > 1) {
7964 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7965 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7966 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7967 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7968 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007969 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
7970 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007971 }
7972 }
7973 }
7974 }
7975
7976 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7977 if (vertexAttributeDescriptionCount > 1) {
7978 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7979 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7980 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7981 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7982 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007983 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
7984 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007985 }
7986 }
7987 }
7988 }
7989
7990 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7991 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7992 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007993 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7994 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7995 "].binding is greater than maxVertexInputBindings",
7996 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007997 }
7998
7999 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8000 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008001 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8002 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8003 "].stride is greater than maxVertexInputBindingStride",
8004 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008005 }
8006
8007 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8008 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8009 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8010 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008011 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8012 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008013 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8014 binding);
8015 }
8016
8017 if (pVertexBindingDescriptions[binding].divisor > 1) {
8018 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8019 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8020 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008021 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8022 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008023 "vertexAttributeInstanceRateDivisor is not enabled",
8024 binding);
8025 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008026 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008027 if (pVertexBindingDescriptions[binding].divisor >
8028 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008029 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8030 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8031 "].divisor is greater than maxVertexAttribDivisor",
8032 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008033 }
8034
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008035 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008036 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008037 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8038 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8039 "].divisor is greater than 1 but inputRate "
8040 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8041 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008042 }
8043 }
8044 }
8045 }
8046
8047 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008048 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008049 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008050 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8051 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8052 "].location is greater than maxVertexInputAttributes",
8053 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008054 }
8055
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008056 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008057 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008058 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8059 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8060 "].binding is greater than maxVertexInputBindings",
8061 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008062 }
8063
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008064 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008065 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008066 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8067 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8068 "].offset is greater than maxVertexInputAttributeOffset",
8069 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008070 }
8071
8072 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8073 VkFormatProperties properties;
8074 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8075 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8076 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008077 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8078 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008079 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8080 attribute);
8081 }
8082 }
8083
8084 return skip;
8085}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008086
8087bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8088 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8089 const void *pValues) const {
8090 bool skip = false;
8091 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8092 // Check that offset + size don't exceed the max.
8093 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8094 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008095 skip |=
8096 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8097 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8098 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008099 }
8100 if (size > max_push_constants_size - offset) {
8101 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008102 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8103 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008104 offset, size, max_push_constants_size);
8105 }
8106
8107 // size needs to be non-zero and a multiple of 4.
8108 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008109 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8110 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008111 }
8112
8113 // offset needs to be a multiple of 4.
8114 if ((offset & 0x3) != 0) {
8115 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008116 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008117 }
8118 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008119}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008120
8121bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8122 uint32_t srcCacheCount,
8123 const VkPipelineCache *pSrcCaches) const {
8124 bool skip = false;
8125 if (pSrcCaches) {
8126 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8127 if (pSrcCaches[index0] == dstCache) {
8128 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8129 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8130 report_data->FormatHandle(dstCache).c_str());
8131 break;
8132 }
8133 }
8134 }
8135 return skip;
8136}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008137
8138bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8139 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8140 uint32_t rangeCount,
8141 const VkImageSubresourceRange *pRanges) const {
8142 bool skip = false;
8143 if (!pColor) {
8144 skip |=
8145 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8146 }
8147 return skip;
8148}
8149
8150bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8151 const VkRenderPassBeginInfo *const rp_begin) const {
8152 bool skip = false;
8153 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8154 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8155 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008156 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008157 func_name, rp_begin->clearValueCount);
8158 }
8159 return skip;
8160}
8161
8162bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8163 VkSubpassContents) const {
8164 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8165 return skip;
8166}
8167
8168bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8169 const VkRenderPassBeginInfo *pRenderPassBegin,
8170 const VkSubpassBeginInfo *) const {
8171 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8172 return skip;
8173}
8174
8175bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8176 const VkSubpassBeginInfo *) const {
8177 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8178 return skip;
8179}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008180
8181bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8182 uint32_t firstDiscardRectangle,
8183 uint32_t discardRectangleCount,
8184 const VkRect2D *pDiscardRectangles) const {
8185 bool skip = false;
8186
8187 if (pDiscardRectangles) {
8188 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8189 const int64_t x_sum =
8190 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8191 if (x_sum > std::numeric_limits<int32_t>::max()) {
8192 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8193 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8194 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8195 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8196 }
8197
8198 const int64_t y_sum =
8199 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8200 if (y_sum > std::numeric_limits<int32_t>::max()) {
8201 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8202 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8203 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8204 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8205 }
8206 }
8207 }
8208
8209 return skip;
8210}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008211
8212bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8213 uint32_t queryCount, size_t dataSize, void *pData,
8214 VkDeviceSize stride, VkQueryResultFlags flags) const {
8215 bool skip = false;
8216
8217 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8218 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8219 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8220 }
8221
8222 return skip;
8223}
ziga-lunargcf340c42021-08-19 00:13:38 +02008224
8225bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8226 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8227 bool skip = false;
8228
8229 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8230 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8231 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8232 ") is not a multiple of 4.",
8233 pConditionalRenderingBegin->offset);
8234 }
8235
8236 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008237}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008238
8239bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8240 VkSurfaceKHR surface,
8241 uint32_t *pSurfaceFormatCount,
8242 VkSurfaceFormatKHR *pSurfaceFormats) const {
8243 bool skip = false;
8244 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8245 skip |= LogError(
8246 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8247 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8248 }
8249 return skip;
8250}
8251
8252bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8253 VkSurfaceKHR surface,
8254 uint32_t *pPresentModeCount,
8255 VkPresentModeKHR *pPresentModes) const {
8256 bool skip = false;
8257 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8258 skip |= LogError(
8259 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8260 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8261 }
8262 return skip;
8263}
8264
8265bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8266 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8267 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8268 bool skip = false;
8269 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8270 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8271 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8272 "VK_GOOGLE_surfaceless_query is not enabled.");
8273 }
8274 return skip;
8275}
8276
8277bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8278 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8279 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8280 bool skip = false;
8281 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8282 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8283 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8284 "VK_GOOGLE_surfaceless_query is not enabled.");
8285 }
8286 return skip;
8287}
8288
8289#ifdef VK_USE_PLATFORM_WIN32_KHR
8290bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8291 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8292 VkPresentModeKHR *pPresentModes) const {
8293 bool skip = false;
8294 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8295 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8296 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8297 "VK_GOOGLE_surfaceless_query is not enabled.");
8298 }
8299 return skip;
8300}
8301#endif // VK_USE_PLATFORM_WIN32_KHR