blob: bac17916e2aa927f3c8ecfc336fe7a5e405d763d [file] [log] [blame]
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070028static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060029
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070036read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); }
37write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); }
38
Jeremy Gebbencbf22862021-03-03 12:01:22 -070039static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070040static ReadWriteLock secondary_cb_map_mutex;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -070041static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); }
42static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070044bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050045 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060046 bool skip = false;
47
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070048 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060049
50 if (result == VK_STRING_ERROR_NONE) {
51 return skip;
52 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070053 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070054 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060055 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070056 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
57 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060058 }
59 return skip;
60}
61
Jeff Bolz46c0ea02019-10-09 13:06:29 -050062bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060063 bool skip = false;
64 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
65 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080066 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
67 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070068 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
69 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
70 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060071 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070072 skip |= LogWarning(instance, kVUIDUndefined,
73 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
74 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
75 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060076 }
77 }
78 return skip;
79}
80
Jeff Bolz46c0ea02019-10-09 13:06:29 -050081bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060082 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060083 // Create and use a local instance extension object, as an actual instance has not been created yet
84 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
85 InstanceExtensions local_instance_extensions;
86 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
87
John Zulauf620755c2018-04-16 11:00:43 -060088 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060089 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
90 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060091 }
92
93 return skip;
94}
95
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060096bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -070097 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060098 // Struct is legal IF it's supported
99 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
100 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
101 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
102 if (enum_iter != dev_exts_enumerated->second.cend()) {
103 return true;
104 }
105 }
106 return false;
107}
108
Tony-LunarG866843d2020-05-13 11:22:42 -0600109bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
110 const VkValidationFeaturesEXT *validation_features) const {
111 bool skip = false;
112 bool debug_printf = false;
113 bool gpu_assisted = false;
114 bool reserve_slot = false;
115 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
116 switch (validation_features->pEnabledValidationFeatures[i]) {
117 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
118 gpu_assisted = true;
119 break;
120
121 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
122 debug_printf = true;
123 break;
124
125 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
126 reserve_slot = true;
127 break;
128
129 default:
130 break;
131 }
132 }
133 if (reserve_slot && !gpu_assisted) {
134 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
135 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
136 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
137 }
138 if (gpu_assisted && debug_printf) {
139 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
140 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
141 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
142 }
143
144 return skip;
145}
146
John Zulauf620755c2018-04-16 11:00:43 -0600147template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700148ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
149 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600150 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700151 ExtEnabled state =
152 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600153 return state;
154}
155
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700156bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500157 const VkAllocationCallbacks *pAllocator,
158 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 bool skip = false;
160 // Note: From the spec--
161 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
162 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
163 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700164 ? pCreateInfo->pApplicationInfo->apiVersion
165 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700166 skip |= validate_api_version(local_api_version, api_version);
167 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700168 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600169 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
170
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700171 return skip;
172}
173
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700174void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700175 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
176 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700177 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
178 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700179 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700180 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700181}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600182
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700183void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
184 // Assume phys_devices is valid
185 assert(phys_devices);
186 for (int i = 0; i < count; ++i) {
187 const auto &phys_device = phys_devices[i];
188 if (0 == physical_device_properties_map.count(phys_device)) {
189 auto phys_dev_props = new VkPhysicalDeviceProperties;
190 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
191 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600192
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700193 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
194 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700195 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700196 std::vector<VkExtensionProperties> ext_props{};
197 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
198 ext_props.resize(ext_count);
199 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
200 for (uint32_t j = 0; j < ext_count; j++) {
201 dev_exts_enumerated.insert(ext_props[j].extensionName);
202 }
203 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600204 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700205 }
206}
207
208void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
209 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
210 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
211 return;
212 }
213
214 if (pPhysicalDeviceCount && pPhysicalDevices) {
215 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
216 }
217}
218
219void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
220 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
221 VkResult result) {
222 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
223 return;
224 }
225
226 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
227 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
228 const auto &group = pPhysicalDeviceGroupProperties[i];
229 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
230 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600231 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700232}
233
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600234void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
235 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
236 delete (it->second);
237 it = physical_device_properties_map.erase(it);
238 }
239};
240
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700241void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700242 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700243 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700244 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700245 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
246 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700247
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248 // Parmeter validation also uses extension data
249 stateless_validation->device_extensions = this->device_extensions;
250
251 VkPhysicalDeviceProperties device_properties = {};
252 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600253 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700254 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
255
256 if (device_extensions.vk_nv_shading_rate_image) {
257 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700258 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
259 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600260 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700261 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
262 }
263
264 if (device_extensions.vk_nv_mesh_shader) {
265 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700266 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
267 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600268 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700269 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
270 }
271
Jason Macnak5c954952019-07-09 15:46:12 -0700272 if (device_extensions.vk_nv_ray_tracing) {
273 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700274 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
275 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700276 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500277 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
278 }
279
sourav parmarcd5fb182020-07-17 12:58:44 -0700280 if (device_extensions.vk_khr_ray_tracing_pipeline) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500281 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700282 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
283 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500284 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
285 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700286 }
287
sourav parmarcd5fb182020-07-17 12:58:44 -0700288 if (device_extensions.vk_khr_acceleration_structure) {
289 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700290 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
291 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700292 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
293 phys_dev_ext_props.acc_structure_props = acc_structure_props;
294 }
295
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700296 if (device_extensions.vk_ext_transform_feedback) {
297 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700298 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
299 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700300 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
301 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
302 }
303
Piers Daniellcb6d8032021-04-19 18:51:26 -0600304 if (device_extensions.vk_ext_vertex_attribute_divisor) {
305 // Get the needed vertex attribute divisor limits
306 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
307 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
308 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
309 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
310 }
311
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800312 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
313
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700314 // Save app-enabled features in this device's validation object
315 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700316 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200317 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
318 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
319 if (features2) {
320 tmp_features2_state.features = features2->features;
321 } else if (pCreateInfo->pEnabledFeatures) {
322 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700323 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200324 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700325 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200326 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700327 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200328 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700329}
330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700331bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500332 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600333 bool skip = false;
334
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200335 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
336 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
337 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600338 }
339
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700340 // If this device supports VK_KHR_portability_subset, it must be enabled
341 const std::string portability_extension_name("VK_KHR_portability_subset");
342 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
343 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
344 bool portability_requested = false;
345
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200346 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
347 skip |=
348 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
349 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
350 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
351 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700352 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
353 portability_requested = true;
354 }
355 }
356
357 if (portability_supported && !portability_requested) {
358 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
359 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
360 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600361 }
362
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200363 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700364 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
365 bool negative_viewport =
366 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200367 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700368 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
369 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
370 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200371 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600372 }
373
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600374 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200375 bool khr_bda =
376 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
377 bool ext_bda =
378 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600379 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700380 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
381 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
382 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600383 }
384 }
385
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600386 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
387 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700388 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600389 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800390 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700391 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800392 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700393 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600394 }
395 }
396
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700397 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500398 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700399 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500400 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
401 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
402 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
403 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700404 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700405 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
406 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
407 skip |= LogError(
408 device,
409 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
410 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
411 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700412 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700413 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600414 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
415 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
416 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
417 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600418 }
419
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700420 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700421 if (vulkan_11_features) {
422 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
423 while (current) {
424 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
425 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
426 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
427 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
428 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
429 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700430 skip |= LogError(
431 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700432 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
433 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
434 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
435 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
436 break;
437 }
438 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
439 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800440
441 // Check features are enabled if matching extension is passed in as well
442 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
443 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
444 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
445 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
446 skip |= LogError(
447 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
448 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
449 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
450 }
451 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700452 }
453
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700454 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700455 if (vulkan_12_features) {
456 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
457 while (current) {
458 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
459 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
460 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
461 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
462 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
463 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
464 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
465 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
466 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
467 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
469 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
470 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700471 skip |= LogError(
472 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700473 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
474 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
475 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
476 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
477 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
478 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
479 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
480 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
481 break;
482 }
483 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
484 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700485 // Check features are enabled if matching extension is passed in as well
486 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
487 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
488 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
489 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
490 skip |= LogError(
491 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
492 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
493 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
494 }
495 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
496 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
497 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
498 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
499 "is not VK_TRUE.",
500 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
501 }
502 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
503 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
504 skip |= LogError(
505 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
506 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
507 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
508 }
509 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
510 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
511 skip |= LogError(
512 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
513 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
514 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
515 }
516 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
517 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
518 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
519 skip |=
520 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
521 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
522 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
523 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
524 }
525 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700526 }
527
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600528 // Validate pCreateInfo->pQueueCreateInfos
529 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600530
531 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700532 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
533 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600534 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700535 skip |=
536 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
537 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
538 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
539 "index value.",
540 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600541 }
542
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700543 if (queue_create_info.pQueuePriorities != nullptr) {
544 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
545 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600546 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700547 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
548 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
549 "] (=%f) is not between 0 and 1 (inclusive).",
550 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600551 }
552 }
553 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700554
555 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700556 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700557 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700558 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700559 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700560 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700561 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700562 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700563 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700564 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700565 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
566 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
567 "protectedMemory feature being set as well.");
568 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600569 }
570 }
571
sfricke-samsung30a57412020-05-15 21:14:54 -0700572 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700573 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700574 VkBool32 variable_pointers = VK_FALSE;
575 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700576 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700577 variable_pointers = vulkan_11_features->variablePointers;
578 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700579 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700580 variable_pointers = variable_pointers_features->variablePointers;
581 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700582 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700583 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700584 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
585 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
586 }
587
sfricke-samsungfd76c342020-05-29 23:13:43 -0700588 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700589 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700590 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700591 VkBool32 multiview_geometry_shader = VK_FALSE;
592 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700593 if (vulkan_11_features) {
594 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700595 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
596 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700597 } else if (multiview_features) {
598 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700599 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
600 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700601 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700602 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700603 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
604 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
605 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700606 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700607 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
608 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
609 }
610
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600611 return skip;
612}
613
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500614bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700615 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700616 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
617 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
618 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600619 }
620
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700621 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600622}
623
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700624bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500625 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100626 bool skip = false;
627
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600628 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700629 skip |=
630 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600631
632 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
633 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
634 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
635 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700636 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
637 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
638 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600639 }
640
641 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
642 // queueFamilyIndexCount uint32_t values
643 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
645 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
646 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
647 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600648 }
649 }
650
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700651 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
652 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
653 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
654 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
655 }
656
657 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
658 skip |=
659 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
660 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
661 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
662 }
663
664 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
665 skip |=
666 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
667 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
668 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
669 }
670
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600671 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
672 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
673 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
674 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700675 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
676 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
677 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600678 }
679 }
680
681 return skip;
682}
683
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700684bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500685 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600686 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600687
688 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800689 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700690 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600691 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
692 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
693 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
694 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700695 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
696 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
697 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600698 }
699
700 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
701 // queueFamilyIndexCount uint32_t values
702 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700703 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
704 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
705 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
706 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600707 }
708 }
709
Dave Houlton413a6782018-05-22 13:01:54 -0600710 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600712 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700713 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600714 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700715 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600716
Dave Houlton413a6782018-05-22 13:01:54 -0600717 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600719 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700720 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600721
Dave Houlton130c0212018-01-29 13:39:56 -0700722 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700723 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
724 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700725 skip |= LogError(
726 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600727 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
728 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700729 }
730
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600731 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100732 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
733 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700734 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
735 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
736 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600737 }
738
739 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700740 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100741 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700742 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
743 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
744 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
745 ") are not equal.",
746 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100747 }
748
749 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
751 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
752 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
753 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100754 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600755 }
756
757 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700758 skip |= LogError(
759 device, "VUID-VkImageCreateInfo-imageType-00957",
760 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600761 }
762 }
763
Dave Houlton130c0212018-01-29 13:39:56 -0700764 // 3D image may have only 1 layer
765 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
767 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700768 }
769
Dave Houlton130c0212018-01-29 13:39:56 -0700770 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
771 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
772 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
773 // At least one of the legal attachment bits must be set
774 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700775 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
776 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700777 }
778 // No flags other than the legal attachment bits may be set
779 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
780 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
782 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700783 }
784 }
785
Jeff Bolzef40fec2018-09-01 22:04:34 -0500786 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700787 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500788 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700789 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700790 ? static_cast<uint32_t>(ceil(log2(max_dim)))
791 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
792 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600793 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700794 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
795 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
796 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600797 }
798
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700799 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700800 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
801 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
802 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600803 }
804
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700805 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700806 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
807 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
808 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100809 }
810
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700811 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700812 skip |= LogError(
813 device, "VUID-VkImageCreateInfo-flags-01924",
814 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
815 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
816 }
817
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600818 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
819 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700820 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
821 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700822 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
823 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
824 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600825 }
826
827 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700828 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600829 // Linear tiling is unsupported
830 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700831 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700832 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
833 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600834 }
835
836 // Sparse 1D image isn't valid
837 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700838 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
839 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600840 }
841
842 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700843 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700844 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
845 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
846 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600847 }
848
849 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700850 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700851 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
852 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
853 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600854 }
855
856 // Multi-sample 2D image when device doesn't support it
857 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700858 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600859 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700860 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
861 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
862 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700863 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600864 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700865 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
866 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
867 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700868 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600869 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700870 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
871 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
872 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700873 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600874 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700875 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
876 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
877 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600878 }
879 }
880 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500881
Jeff Bolz9af91c52018-09-01 21:53:57 -0500882 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
883 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700884 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
885 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
886 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500887 }
888 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700889 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
890 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
891 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500892 }
893 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700894 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
895 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
896 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500897 }
898 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500899
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700900 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600901 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700902 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
903 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
904 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500905 }
906
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700907 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700908 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
909 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800910 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
911 "depth/stencil format.",
912 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500913 }
914
Dave Houlton142c4cb2018-10-17 15:04:41 -0600915 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700916 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
917 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
918 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
919 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500920 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600921 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700922 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
923 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
924 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
925 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500926 }
927 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500928
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700929 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800930 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700931 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
932 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800933 "format (%s) must be a depth or depth/stencil format.",
934 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700935 }
936
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700937 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500938 if (image_stencil_struct != nullptr) {
939 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
940 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
941 // No flags other than the legal attachment bits may be set
942 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
943 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700944 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
945 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
946 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
947 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500948 }
949 }
950
sfricke-samsung61a57c02021-01-10 21:35:12 -0800951 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500952 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
953 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800954 skip |= LogError(
955 device, "VUID-VkImageCreateInfo-Format-02536",
956 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
957 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
958 "maxFramebufferWidth (%u)",
959 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500960 }
961
962 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800963 skip |= LogError(
964 device, "VUID-VkImageCreateInfo-format-02537",
965 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
966 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
967 "maxFramebufferHeight (%u)",
968 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500969 }
970 }
971
972 if (!physical_device_features.shaderStorageImageMultisample &&
973 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
974 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
975 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700976 LogError(device, "VUID-VkImageCreateInfo-format-02538",
977 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
978 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
979 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500980 }
981
982 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
983 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700984 skip |= LogError(
985 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500986 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
987 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
988 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
989 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
990 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700991 skip |= LogError(
992 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500993 "vkCreateImage(): Depth-stencil image in which usage does not include "
994 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
995 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
996 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
997 }
998
999 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1000 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001001 skip |= LogError(
1002 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001003 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1004 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1005 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1006 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1007 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001008 skip |= LogError(
1009 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001010 "vkCreateImage(): Depth-stencil image in which usage does not include "
1011 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1012 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1013 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1014 }
1015 }
1016 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001017
1018 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1019 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1020 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1021 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1022 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1023 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001024
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001025 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001026 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001027 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1028 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001029 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1030 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1031 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1032 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1033 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1034 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1035 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001036 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001037 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1038 } else if (drm_format_mod_list != nullptr) {
1039 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1040 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1041 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001042 }
1043 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1044 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1045 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1046 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1047 "in the pNext chain");
1048 }
1049 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001050
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001051 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001052 bool image_create_maybe_linear = false;
1053 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1054 image_create_maybe_linear = true;
1055 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1056 image_create_maybe_linear = false;
1057 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1058 image_create_maybe_linear =
1059 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001060 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001061 }
1062
1063 // If multi-sample, validate type, usage, tiling and mip levels.
1064 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001065 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001066 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1067 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1068 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1069 }
1070
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001071 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001072 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1073 image_create_maybe_linear)) {
1074 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1075 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1076 }
1077
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001078 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1079 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1080 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1081 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1082 "imageType must be VK_IMAGE_TYPE_2D.");
1083 }
1084 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1085 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1086 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1087 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1088 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001089 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001090 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001091 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1092 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1093 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1094 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1095 }
1096 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1097 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1098 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1099 "imageType must be VK_IMAGE_TYPE_2D.");
1100 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001101 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001102 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1103 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1104 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1105 }
1106 if (pCreateInfo->mipLevels != 1) {
1107 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1108 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1109 pCreateInfo->mipLevels);
1110 }
1111 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001112
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001113 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001114 if (swapchain_create_info != nullptr) {
1115 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1116 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1117 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1118 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1119 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1120 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1121
1122 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1123 // also implicitly forces the check above that extent.depth is 1
1124 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1125 string_VkImageType(pCreateInfo->imageType));
1126 }
1127 if (pCreateInfo->mipLevels != 1) {
1128 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1129 pCreateInfo->mipLevels);
1130 }
1131 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1132 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1133 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1134 }
1135 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1136 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1137 base_message, string_VkImageTiling(pCreateInfo->tiling));
1138 }
1139 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1140 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1141 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1142 }
1143 const VkImageCreateFlags valid_flags =
1144 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001145 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001146 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001147 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001148 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001149 }
1150 }
1151 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001152
1153 // If Chroma subsampled format ( _420_ or _422_ )
1154 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1155 skip |=
1156 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1157 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1158 ") must be a multiple of 2.",
1159 string_VkFormat(image_format), pCreateInfo->extent.width);
1160 }
1161 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1162 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1163 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1164 ") must be a multiple of 2.",
1165 string_VkFormat(image_format), pCreateInfo->extent.height);
1166 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001167
1168 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1169 if (format_list_info) {
1170 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1171 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1172 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1173 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1174 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1175 viewFormatCount);
1176 }
1177 // Check if viewFormatCount is not zero that it is all compatible
1178 for (uint32_t i = 0; i < viewFormatCount; i++) {
1179 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1180 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1181 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1182 "VkImageCreateInfo::format (%s) are not compatible.",
1183 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1184 }
1185 }
1186 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001187 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001188
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001189 return skip;
1190}
1191
Jeff Bolz99e3f632020-03-24 22:59:22 -05001192bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1193 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1194 bool skip = false;
1195
1196 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001197 // Validate feature set if using CUBE_ARRAY
1198 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1199 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1200 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1201 "enabling the imageCubeArray feature.");
1202 }
1203
Jeff Bolz99e3f632020-03-24 22:59:22 -05001204 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1205 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1206 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001207 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001208 pCreateInfo->subresourceRange.layerCount);
1209 }
1210 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001211 skip |= LogError(
1212 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1213 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1214 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001215 }
1216 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001217
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001218 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001219 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1220 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1221 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1222 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1223 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1224 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1225 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1226 }
1227 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1228 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1229 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1230 "not an ASTC format.",
1231 string_VkFormat(pCreateInfo->format));
1232 }
1233 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001234
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001235 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001236 if (ycbcr_conversion != nullptr) {
1237 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1238 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1239 skip |= LogError(
1240 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1241 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1242 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1243 "r swizzle = %s\n"
1244 "g swizzle = %s\n"
1245 "b swizzle = %s\n"
1246 "a swizzle = %s\n",
1247 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1248 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1249 }
1250 }
1251 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001252 }
1253 return skip;
1254}
1255
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001256bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001257 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001258 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001259
1260 // Note: for numerical correctness
1261 // - float comparisons should expect NaN (comparison always false).
1262 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1263
1264 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001265 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001266 if (v1_f <= 0.0f) return true;
1267
1268 float intpart;
1269 const float fract = modff(v1_f, &intpart);
1270
1271 assert(std::numeric_limits<float>::radix == 2);
1272 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1273 if (intpart >= u32_max_plus1) return false;
1274
1275 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001276 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001277 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001278 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001279 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001280 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001281 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001282 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001283 };
1284
1285 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1286 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1287 return (v1_f <= v2_f);
1288 };
1289
1290 // width
1291 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001292 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001293
1294 if (!(viewport.width > 0.0f)) {
1295 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001296 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1297 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001298 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1299 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001300 skip |= LogError(object, "VUID-VkViewport-width-01771",
1301 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1302 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001303 }
1304
1305 // height
1306 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001307 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001308 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001309
1310 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1311 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001312 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1313 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001314 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1315 height_healthy = false;
1316
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001317 skip |= LogError(object, "VUID-VkViewport-height-01773",
1318 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1319 ").",
1320 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001321 }
1322
1323 // x
1324 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001325 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001326 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001327 skip |= LogError(object, "VUID-VkViewport-x-01774",
1328 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1329 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001330 }
1331
1332 // x + width
1333 if (x_healthy && width_healthy) {
1334 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001335 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001336 skip |= LogError(
1337 object, "VUID-VkViewport-x-01232",
1338 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1339 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1340 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001341 }
1342 }
1343
1344 // y
1345 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001346 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001347 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001348 skip |= LogError(object, "VUID-VkViewport-y-01775",
1349 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1350 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001351 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001352 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001353 skip |= LogError(object, "VUID-VkViewport-y-01776",
1354 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1355 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001356 }
1357
1358 // y + height
1359 if (y_healthy && height_healthy) {
1360 const float boundary = viewport.y + viewport.height;
1361
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001362 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001363 skip |= LogError(object, "VUID-VkViewport-y-01233",
1364 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1365 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1366 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001367 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001368 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001369 LogError(object, "VUID-VkViewport-y-01777",
1370 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1371 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1372 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001373 }
1374 }
1375
sfricke-samsungfd06d422021-01-22 02:17:21 -08001376 // The extension was not created with a feature bit whichs prevents displaying the 2 variations of the VUIDs
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001377 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001378 // minDepth
1379 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001380 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001381 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001382 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1383 "[0.0, 1.0] range.",
1384 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001385 }
1386
1387 // maxDepth
1388 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001389 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001390 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001391 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1392 "[0.0, 1.0] range.",
1393 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001394 }
1395 }
1396
1397 return skip;
1398}
1399
Dave Houlton142c4cb2018-10-17 15:04:41 -06001400struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001401 VkShadingRatePaletteEntryNV shadingRate;
1402 uint32_t width;
1403 uint32_t height;
1404};
1405
1406// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001407static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001408 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1409 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1410 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1411 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1412 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1413 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001414};
1415
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001416bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001417 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001418
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001419 SampleOrderInfo *sample_order_info;
1420 uint32_t info_idx = 0;
1421 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1422 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1423 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001424 break;
1425 }
1426 }
1427
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001428 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001429 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1430 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1431 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001432 return skip;
1433 }
1434
Dave Houlton142c4cb2018-10-17 15:04:41 -06001435 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001436 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001437 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1438 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1439 ") must "
1440 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1441 "is set in framebufferNoAttachmentsSampleCounts.",
1442 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001443 }
1444
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001445 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001446 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1447 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1448 ") must "
1449 "be equal to the product of sampleCount (=%" PRIu32
1450 "), the fragment width for shadingRate "
1451 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001452 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001453 }
1454
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001455 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001456 skip |= LogError(
1457 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001458 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1459 ") must "
1460 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001461 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001462 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001463
1464 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001465 // the first width*height*sampleCount bits to all be set. Note: There is no
1466 // guarantee that 64 bits is enough, but practically it's unlikely for an
1467 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001468 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001469 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001470 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001471 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1472 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001473 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1474 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001475 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001476 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001477 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1478 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001479 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001480 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001481 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1482 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001483 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001484 uint32_t idx =
1485 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1486 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001487 }
1488
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001489 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1490 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001491 skip |= LogError(
1492 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001493 "The array pSampleLocations must contain exactly one entry for "
1494 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001495 }
1496
1497 return skip;
1498}
1499
sfricke-samsung51303fb2021-05-09 19:09:13 -07001500bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1501 const VkAllocationCallbacks *pAllocator,
1502 VkPipelineLayout *pPipelineLayout) const {
1503 bool skip = false;
1504 // Validate layout count against device physical limit
1505 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1506 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
1507 "vkCreatePipelineLayout(): setLayoutCount (%d) exceeds physical device maxBoundDescriptorSets limit (%d).",
1508 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1509 }
1510
1511 // Validate Push Constant ranges
1512 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1513 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1514 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1515 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1516 // Check that offset + size don't exceed the max.
1517 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1518 if (offset >= max_push_constants_size) {
1519 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
1520 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) that exceeds this "
1521 "device's maxPushConstantSize of %u.",
1522 i, offset, max_push_constants_size);
1523 }
1524 if (size > max_push_constants_size - offset) {
1525 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
1526 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u] offset (%u) and size (%u) "
1527 "together exceeds this device's maxPushConstantSize of %u.",
1528 i, offset, size, max_push_constants_size);
1529 }
1530
1531 // size needs to be non-zero and a multiple of 4.
1532 if (size == 0) {
1533 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
1534 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not greater than zero.",
1535 i, size);
1536 }
1537 if (size & 0x3) {
1538 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
1539 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not a multiple of 4.", i,
1540 size);
1541 }
1542
1543 // offset needs to be a multiple of 4.
1544 if ((offset & 0x3) != 0) {
1545 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
1546 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) is not a multiple of 4.",
1547 i, offset);
1548 }
1549 }
1550
1551 // 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.
1552 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1553 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1554 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
1555 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1556 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %d and %d.", i, j);
1557 }
1558 }
1559 }
1560 return skip;
1561}
1562
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001563bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1564 uint32_t createInfoCount,
1565 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1566 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001567 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001568 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001569
1570 if (pCreateInfos != nullptr) {
1571 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001572 bool has_dynamic_viewport = false;
1573 bool has_dynamic_scissor = false;
1574 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001575 bool has_dynamic_depth_bias = false;
1576 bool has_dynamic_blend_constant = false;
1577 bool has_dynamic_depth_bounds = false;
1578 bool has_dynamic_stencil_compare = false;
1579 bool has_dynamic_stencil_write = false;
1580 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001581 bool has_dynamic_viewport_w_scaling_nv = false;
1582 bool has_dynamic_discard_rectangle_ext = false;
1583 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001584 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001585 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001586 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001587 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001588 bool has_dynamic_cull_mode = false;
1589 bool has_dynamic_front_face = false;
1590 bool has_dynamic_primitive_topology = false;
1591 bool has_dynamic_viewport_with_count = false;
1592 bool has_dynamic_scissor_with_count = false;
1593 bool has_dynamic_vertex_input_binding_stride = false;
1594 bool has_dynamic_depth_test_enable = false;
1595 bool has_dynamic_depth_write_enable = false;
1596 bool has_dynamic_depth_compare_op = false;
1597 bool has_dynamic_depth_bounds_test_enable = false;
1598 bool has_dynamic_stencil_test_enable = false;
1599 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001600 bool has_patch_control_points = false;
1601 bool has_rasterizer_discard_enable = false;
1602 bool has_depth_bias_enable = false;
1603 bool has_logic_op = false;
1604 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001605 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001606 if (pCreateInfos[i].pDynamicState != nullptr) {
1607 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1608 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1609 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001610 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1611 if (has_dynamic_viewport == true) {
1612 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1613 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1614 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1615 i);
1616 }
1617 has_dynamic_viewport = true;
1618 }
1619 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1620 if (has_dynamic_scissor == true) {
1621 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1622 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1623 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1624 i);
1625 }
1626 has_dynamic_scissor = true;
1627 }
1628 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1629 if (has_dynamic_line_width == true) {
1630 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1631 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1632 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1633 i);
1634 }
1635 has_dynamic_line_width = true;
1636 }
1637 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1638 if (has_dynamic_depth_bias == true) {
1639 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1640 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1641 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1642 i);
1643 }
1644 has_dynamic_depth_bias = true;
1645 }
1646 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1647 if (has_dynamic_blend_constant == true) {
1648 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1649 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1650 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1651 i);
1652 }
1653 has_dynamic_blend_constant = true;
1654 }
1655 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1656 if (has_dynamic_depth_bounds == true) {
1657 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1658 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1659 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1660 i);
1661 }
1662 has_dynamic_depth_bounds = true;
1663 }
1664 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1665 if (has_dynamic_stencil_compare == true) {
1666 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1667 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1668 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1669 i);
1670 }
1671 has_dynamic_stencil_compare = true;
1672 }
1673 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1674 if (has_dynamic_stencil_write == true) {
1675 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1676 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1677 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1678 i);
1679 }
1680 has_dynamic_stencil_write = true;
1681 }
1682 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1683 if (has_dynamic_stencil_reference == true) {
1684 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1685 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1686 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1687 i);
1688 }
1689 has_dynamic_stencil_reference = true;
1690 }
1691 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1692 if (has_dynamic_viewport_w_scaling_nv == true) {
1693 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1694 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1695 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1696 i);
1697 }
1698 has_dynamic_viewport_w_scaling_nv = true;
1699 }
1700 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1701 if (has_dynamic_discard_rectangle_ext == true) {
1702 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1703 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1704 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1705 i);
1706 }
1707 has_dynamic_discard_rectangle_ext = true;
1708 }
1709 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1710 if (has_dynamic_sample_locations_ext == true) {
1711 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1712 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1713 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1714 i);
1715 }
1716 has_dynamic_sample_locations_ext = true;
1717 }
1718 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1719 if (has_dynamic_exclusive_scissor_nv == true) {
1720 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1721 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1722 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1723 i);
1724 }
1725 has_dynamic_exclusive_scissor_nv = true;
1726 }
1727 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1728 if (has_dynamic_shading_rate_palette_nv == true) {
1729 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1730 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1731 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1732 i);
1733 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001734 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001735 }
1736 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1737 if (has_dynamic_viewport_course_sample_order_nv == true) {
1738 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1739 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1740 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1741 i);
1742 }
1743 has_dynamic_viewport_course_sample_order_nv = true;
1744 }
1745 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1746 if (has_dynamic_line_stipple == true) {
1747 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1748 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1749 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1750 i);
1751 }
1752 has_dynamic_line_stipple = true;
1753 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001754 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1755 if (has_dynamic_cull_mode) {
1756 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1757 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1758 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1759 i);
1760 }
1761 has_dynamic_cull_mode = true;
1762 }
1763 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1764 if (has_dynamic_front_face) {
1765 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1766 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1767 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1768 i);
1769 }
1770 has_dynamic_front_face = true;
1771 }
1772 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1773 if (has_dynamic_primitive_topology) {
1774 skip |= LogError(
1775 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1776 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1777 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1778 i);
1779 }
1780 has_dynamic_primitive_topology = true;
1781 }
1782 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1783 if (has_dynamic_viewport_with_count) {
1784 skip |= LogError(
1785 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1786 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1787 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1788 i);
1789 }
1790 has_dynamic_viewport_with_count = true;
1791 }
1792 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1793 if (has_dynamic_scissor_with_count) {
1794 skip |= LogError(
1795 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1796 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1797 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1798 i);
1799 }
1800 has_dynamic_scissor_with_count = true;
1801 }
1802 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1803 if (has_dynamic_vertex_input_binding_stride) {
1804 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1805 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1806 "listed twice in the "
1807 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1808 i);
1809 }
1810 has_dynamic_vertex_input_binding_stride = true;
1811 }
1812 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1813 if (has_dynamic_depth_test_enable) {
1814 skip |= LogError(
1815 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1816 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1817 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1818 i);
1819 }
1820 has_dynamic_depth_test_enable = true;
1821 }
1822 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1823 if (has_dynamic_depth_write_enable) {
1824 skip |= LogError(
1825 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1826 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1827 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1828 i);
1829 }
1830 has_dynamic_depth_write_enable = true;
1831 }
1832 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1833 if (has_dynamic_depth_compare_op) {
1834 skip |=
1835 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1836 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1837 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1838 i);
1839 }
1840 has_dynamic_depth_compare_op = true;
1841 }
1842 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1843 if (has_dynamic_depth_bounds_test_enable) {
1844 skip |= LogError(
1845 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1846 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1847 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1848 i);
1849 }
1850 has_dynamic_depth_bounds_test_enable = true;
1851 }
1852 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1853 if (has_dynamic_stencil_test_enable) {
1854 skip |= LogError(
1855 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1856 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1857 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1858 i);
1859 }
1860 has_dynamic_stencil_test_enable = true;
1861 }
1862 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1863 if (has_dynamic_stencil_op) {
1864 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1865 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1866 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1867 i);
1868 }
1869 has_dynamic_stencil_op = true;
1870 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001871 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1872 // Not allowed for graphics pipelines
1873 skip |= LogError(
1874 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1875 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1876 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1877 i, state_index);
1878 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001879 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1880 if (has_patch_control_points) {
1881 skip |= LogError(
1882 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1883 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1884 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1885 i);
1886 }
1887 has_patch_control_points = true;
1888 }
1889 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1890 if (has_rasterizer_discard_enable) {
1891 skip |= LogError(
1892 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1893 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1894 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1895 i);
1896 }
1897 has_rasterizer_discard_enable = true;
1898 }
1899 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1900 if (has_depth_bias_enable) {
1901 skip |= LogError(
1902 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1903 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1904 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1905 i);
1906 }
1907 has_depth_bias_enable = true;
1908 }
1909 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1910 if (has_logic_op) {
1911 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1912 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1913 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1914 i);
1915 }
1916 has_logic_op = true;
1917 }
1918 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1919 if (has_primitive_restart_enable) {
1920 skip |= LogError(
1921 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1922 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1923 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1924 i);
1925 }
1926 has_primitive_restart_enable = true;
1927 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001928 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1929 if (has_dynamic_vertex_input) {
1930 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1931 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1932 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1933 i);
1934 }
1935 has_dynamic_vertex_input = true;
1936 }
Petr Kraus299ba622017-11-24 03:09:03 +01001937 }
1938 }
1939
sfricke-samsung3b944422021-01-23 02:15:19 -08001940 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1941 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1942 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1943 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1944 i);
1945 }
1946
1947 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1948 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1949 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1950 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1951 i);
1952 }
1953
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001954 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001955 if ((feedback_struct != nullptr) &&
1956 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001957 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1958 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1959 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1960 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1961 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001962 }
1963
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001964 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001965
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001966 // Collect active stages and other information
1967 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001968 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001969 bool has_eval = false;
1970 bool has_control = false;
1971 if (pCreateInfos[i].pStages != nullptr) {
1972 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1973 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1974
1975 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1976 has_control = true;
1977 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1978 has_eval = true;
1979 }
1980
1981 skip |= validate_string(
1982 "vkCreateGraphicsPipelines",
1983 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1984 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1985 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001986 }
1987
1988 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1989 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1990 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1991 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1992 pCreateInfos[i].pTessellationState,
1993 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1994 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1995
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001996 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001997 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1998
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001999 skip |= validate_struct_pnext(
2000 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2001 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2002 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2003 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2004 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2005 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002006
2007 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2008 pCreateInfos[i].pTessellationState->flags,
2009 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2010 }
2011
2012 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2013 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2014 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2015 pCreateInfos[i].pInputAssemblyState,
2016 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2017 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2018
2019 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2020 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002021 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002022
2023 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2024 pCreateInfos[i].pInputAssemblyState->flags,
2025 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2026
2027 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2028 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2029 pCreateInfos[i].pInputAssemblyState->topology,
2030 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2031
2032 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2033 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2034 }
2035
2036 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002037 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002038
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002039 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002040 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2041 "vkCreateGraphicsPipelines: pararameter "
2042 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
2043 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002044 }
2045
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002046 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002047 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2048 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2049 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2050 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002051 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2052 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002053 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002054 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2055 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002056 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002057 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2058 skip |=
2059 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2060 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2061 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2062 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2063 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2064
2065 skip |= validate_array(
2066 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2067 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2068 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2069 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2070
2071 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002072 for (uint32_t vertex_binding_description_index = 0;
2073 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2074 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002075 skip |= validate_ranged_enum(
2076 "vkCreateGraphicsPipelines",
2077 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2078 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002079 pCreateInfos[i]
2080 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2081 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002082 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2083 }
2084 }
2085
2086 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002087 for (uint32_t vertex_attribute_description_index = 0;
2088 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2089 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002090 skip |= validate_ranged_enum(
2091 "vkCreateGraphicsPipelines",
2092 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2093 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002094 pCreateInfos[i]
2095 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2096 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002097 "VUID-VkVertexInputAttributeDescription-format-parameter");
2098 }
2099 }
2100
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002101 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002102 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2103 "vkCreateGraphicsPipelines: pararameter "
2104 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2105 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2106 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002107 }
2108
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002109 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002110 skip |=
2111 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2112 "vkCreateGraphicsPipelines: pararameter "
2113 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2114 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2115 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002116 }
2117
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002118 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002119 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2120 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002121 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2122 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002123 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2124 "vkCreateGraphicsPipelines: parameter "
2125 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2126 "(%" PRIu32 ") is not distinct.",
2127 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002128 }
2129 vertex_bindings.insert(vertex_bind_desc.binding);
2130
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002131 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002132 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2133 "vkCreateGraphicsPipelines: parameter "
2134 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2135 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2136 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002137 }
2138
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002139 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002140 skip |=
2141 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2142 "vkCreateGraphicsPipelines: parameter "
2143 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2144 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2145 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002146 }
2147 }
2148
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002149 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002150 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2151 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002152 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2153 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002154 skip |= LogError(
2155 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002156 "vkCreateGraphicsPipelines: parameter "
2157 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2158 i, d, vertex_attrib_desc.location);
2159 }
2160 attribute_locations.insert(vertex_attrib_desc.location);
2161
2162 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2163 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002164 skip |= LogError(
2165 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002166 "vkCreateGraphicsPipelines: parameter "
2167 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2168 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2169 i, d, vertex_attrib_desc.binding, i);
2170 }
2171
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002172 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002173 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2174 "vkCreateGraphicsPipelines: parameter "
2175 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2176 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2177 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002178 }
2179
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002180 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002181 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2182 "vkCreateGraphicsPipelines: parameter "
2183 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2184 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2185 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002186 }
2187
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002188 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002189 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2190 "vkCreateGraphicsPipelines: parameter "
2191 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2192 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2193 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002194 }
2195 }
2196 }
2197
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002198 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2199 if (has_control && has_eval) {
2200 if (pCreateInfos[i].pTessellationState == nullptr) {
2201 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2202 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2203 "shader stage and a tessellation evaluation shader stage, "
2204 "pCreateInfos[%d].pTessellationState must not be NULL.",
2205 i, i);
2206 } else {
2207 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2208 skip |= validate_struct_pnext(
2209 "vkCreateGraphicsPipelines",
2210 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2211 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2212 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2213 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002214
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002215 skip |= validate_reserved_flags(
2216 "vkCreateGraphicsPipelines",
2217 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2218 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002219
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002220 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2221 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2222 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2223 "vkCreateGraphicsPipelines: invalid parameter "
2224 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2225 "should be >0 and <=%u.",
2226 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2227 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002228 }
2229 }
2230 }
2231
2232 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2233 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2234 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2235 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002236 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2237 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2238 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2239 "].pViewportState (=NULL) is not a valid pointer.",
2240 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002241 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002242 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2243
2244 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002245 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2246 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2247 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2248 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002249 }
2250
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002251 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002252 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002253 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2254 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002255 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2256 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002257 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002258 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002259 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002260 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002261 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002262 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2263 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002264 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2265 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2266 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002267 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002268
2269 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002270 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002271 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002272 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002273
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002274 auto exclusive_scissor_struct =
2275 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2276 auto shading_rate_image_struct =
2277 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2278 auto coarse_sample_order_struct =
2279 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002280 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002281 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002282 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002283 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002284
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002285 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002286 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002287 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2288 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2289 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2290 ") is not 1.",
2291 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002292 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002293
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002294 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002295 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2296 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2297 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2298 ") is not 1.",
2299 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002300 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002301
Dave Houlton142c4cb2018-10-17 15:04:41 -06002302 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2303 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002304 skip |= LogError(
2305 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2306 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2307 "disabled, but pCreateInfos[%" PRIu32
2308 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2309 ") is not 1.",
2310 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002311 }
2312
Jeff Bolz9af91c52018-09-01 21:53:57 -05002313 if (shading_rate_image_struct &&
2314 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002315 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2316 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2317 "disabled, but pCreateInfos[%" PRIu32
2318 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2319 ") is neither 0 nor 1.",
2320 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002321 }
2322
Petr Krausa6103552017-11-16 21:21:58 +01002323 } else { // multiViewport enabled
2324 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002325 if (!has_dynamic_viewport_with_count) {
2326 skip |= LogError(
2327 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2328 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2329 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002330 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002331 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2332 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2333 "].pViewportState->viewportCount (=%" PRIu32
2334 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2335 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002336 } else if (has_dynamic_viewport_with_count) {
2337 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2338 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2339 "].pViewportState->viewportCount (=%" PRIu32
2340 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2341 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002342 }
Petr Krausa6103552017-11-16 21:21:58 +01002343
2344 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002345 if (!has_dynamic_scissor_with_count) {
2346 skip |= LogError(
2347 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2348 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2349 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002350 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002351 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2352 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2353 "].pViewportState->scissorCount (=%" PRIu32
2354 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2355 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002356 } else if (has_dynamic_scissor_with_count) {
2357 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2358 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2359 "].pViewportState->scissorCount (=%" PRIu32
2360 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2361 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002362 }
2363 }
2364
ziga-lunarg845883b2021-07-14 15:05:00 +02002365 if (!has_dynamic_scissor && viewport_state.pScissors) {
2366 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2367 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002368
2369 if (scissor.offset.x < 0) {
2370 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2371 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2372 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2373 scissor.offset.x, i, scissor_i);
2374 }
2375
2376 if (scissor.offset.y < 0) {
2377 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2378 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2379 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2380 scissor.offset.y, i, scissor_i);
2381 }
2382
ziga-lunarg845883b2021-07-14 15:05:00 +02002383 const int64_t x_sum =
2384 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2385 if (x_sum > std::numeric_limits<int32_t>::max()) {
2386 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2387 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2388 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2389 "] will overflow int32_t.",
2390 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2391 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002392
ziga-lunarg845883b2021-07-14 15:05:00 +02002393 const int64_t y_sum =
2394 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2395 if (y_sum > std::numeric_limits<int32_t>::max()) {
2396 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2397 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2398 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2399 "] will overflow int32_t.",
2400 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2401 }
2402 }
2403 }
2404
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002405 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002406 skip |=
2407 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2408 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2409 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2410 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002411 }
2412
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002413 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002414 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2415 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2416 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2417 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2418 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002419 }
2420
Piers Daniell39842ee2020-07-10 16:42:33 -06002421 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2422 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002423 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2424 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2425 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2426 "].pViewportState->viewportCount (=%" PRIu32 ").",
2427 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002428 }
2429
Dave Houlton142c4cb2018-10-17 15:04:41 -06002430 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002431 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002432 skip |=
2433 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2434 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2435 ") must be zero or identical to pCreateInfos[%" PRIu32
2436 "].pViewportState->viewportCount (=%" PRIu32 ").",
2437 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002438 }
2439
Dave Houlton142c4cb2018-10-17 15:04:41 -06002440 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002441 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002442 skip |= LogError(
2443 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002444 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2445 "] "
2446 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2447 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2448 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002449 }
2450
Petr Krausa6103552017-11-16 21:21:58 +01002451 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002452 skip |= LogError(
2453 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002454 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2455 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002456 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2457 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002458 }
2459
2460 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002461 skip |= LogError(
2462 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002463 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2464 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002465 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2466 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002467 }
2468
Jeff Bolz3e71f782018-08-29 23:15:45 -05002469 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002470 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2471 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2472 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002473 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002474 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2475 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2476 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2477 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002478 }
2479
Jeff Bolz9af91c52018-09-01 21:53:57 -05002480 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002481 shading_rate_image_struct->viewportCount > 0 &&
2482 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002483 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002484 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002485 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002486 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2487 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002488 i, i);
2489 }
2490
Chris Mayer328d8212018-12-11 14:16:18 +01002491 if (vp_swizzle_struct) {
2492 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002493 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2494 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2495 " does "
2496 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2497 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002498 }
2499 }
2500
Petr Krausb3fcdb42018-01-09 22:09:09 +01002501 // validate the VkViewports
2502 if (!has_dynamic_viewport && viewport_state.pViewports) {
2503 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2504 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002505 const char *fn_name = "vkCreateGraphicsPipelines";
2506 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2507 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2508 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002509 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002510 }
2511 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002512
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002513 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002514 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2515 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2516 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2517 "VK_NV_clip_space_w_scaling extension is not enabled.",
2518 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002519 }
2520
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002521 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2523 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2524 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2525 "VK_EXT_discard_rectangles extension is not enabled.",
2526 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002527 }
2528
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002529 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002530 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2531 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2532 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2533 "VK_EXT_sample_locations extension is not enabled.",
2534 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002535 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002536
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002537 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002538 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2539 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2540 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2541 "VK_NV_scissor_exclusive extension is not enabled.",
2542 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002543 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002544
2545 if (coarse_sample_order_struct &&
2546 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2547 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002548 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2549 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2550 "] "
2551 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2552 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2553 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002554 }
2555
2556 if (coarse_sample_order_struct) {
2557 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002558 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002559 }
2560 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002561
2562 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2563 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002564 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2565 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2566 "] "
2567 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2568 ") "
2569 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2570 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002571 }
2572 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002573 skip |= LogError(
2574 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002575 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2576 "] "
2577 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2578 i);
2579 }
2580 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002581 }
2582
2583 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002584 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2585 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2586 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2587 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002588 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002589 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002590 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002591 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2592 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002593 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002594 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002595 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002596 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002597 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002598 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002599 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002600 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2601 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002602
2603 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002604 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002605 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002606 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002607
2608 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002609 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002610 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2611 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2612
2613 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002614 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002615 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2616 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002617 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002618 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002619
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002620 skip |= validate_flags(
2621 "vkCreateGraphicsPipelines",
2622 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2623 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002624 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002625
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002626 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002627 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002628 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2629 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2630
2631 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002632 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002633 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2634 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2635
2636 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002637 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002638 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2639 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2640 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002641 }
John Zulauf7acac592017-11-06 11:15:53 -07002642 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002643 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002644 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2645 "vkCreateGraphicsPipelines(): parameter "
2646 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2647 i);
John Zulauf7acac592017-11-06 11:15:53 -07002648 }
2649 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2650 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2651 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002652 skip |= LogError(
2653 device,
2654
Dave Houlton413a6782018-05-22 13:01:54 -06002655 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002656 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002657 }
2658 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002659
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002660 const auto *line_state =
2661 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002662
2663 if (line_state) {
2664 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2665 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2666 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2667 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002668 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2669 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2670 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2671 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002672 }
2673 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2674 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002675 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2676 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2677 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2678 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002679 }
2680 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2681 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002682 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2683 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2684 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2685 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002686 }
2687 }
2688 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2689 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2690 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002691 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2692 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2693 "range [1,256].",
2694 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002695 }
2696 }
2697 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002698 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002699 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2700 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002701 skip |=
2702 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2703 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2704 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2705 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002706 }
2707 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2708 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002709 skip |=
2710 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2711 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2712 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2713 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002714 }
2715 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2716 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002717 skip |=
2718 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2719 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2720 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2721 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002722 }
2723 if (line_state->stippledLineEnable) {
2724 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2725 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002726 skip |=
2727 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2728 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2729 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2730 "stippledRectangularLines feature.",
2731 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002732 }
2733 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2734 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002735 skip |=
2736 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2737 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2738 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2739 "stippledBresenhamLines feature.",
2740 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002741 }
2742 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2743 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002744 skip |=
2745 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2746 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2747 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2748 "stippledSmoothLines feature.",
2749 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002750 }
2751 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2752 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002753 skip |=
2754 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2755 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2756 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2757 "stippledRectangularLines and strictLines features.",
2758 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002759 }
2760 }
2761 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002762 }
2763
Petr Krause91f7a12017-12-14 20:57:36 +01002764 bool uses_color_attachment = false;
2765 bool uses_depthstencil_attachment = false;
2766 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002767 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002768 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2769 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002770 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002771 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002772 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002773 }
2774 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002775 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002776 }
Petr Krause91f7a12017-12-14 20:57:36 +01002777 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002778 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002779 }
2780
2781 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002782 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002783 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002784 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002785 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002786 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002787
2788 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002789 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002790 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002791 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002792
2793 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002794 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002795 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2796 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2797
2798 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002799 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002800 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2801 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2802
2803 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002804 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002805 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2806 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002807 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002808
2809 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002810 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002811 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2812 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2813
2814 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002815 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002816 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2817 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2818
2819 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002820 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002821 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2822 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002823 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002824
2825 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002826 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002827 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2828 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002829 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830
2831 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002832 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002833 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2834 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002835 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002836
2837 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002838 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002839 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2840 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002841 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002842
2843 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002844 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002845 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2846 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002847 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002848
2849 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002850 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002851 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2852 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002853 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002854
2855 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002856 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002857 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2858 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002859 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002860
2861 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002862 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002863 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2864 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002865 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002866
2867 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002868 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002869 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2870 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2871 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002872 }
2873 }
2874
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002875 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002876 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2877
Petr Krause91f7a12017-12-14 20:57:36 +01002878 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002879 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2880 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2881 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2882 pCreateInfos[i].pColorBlendState,
2883 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2884 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2885
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002886 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002887 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002888 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2889 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002890 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2891 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002892 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2893 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894
2895 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002896 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002898 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002899
2900 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002901 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002902 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2903 pCreateInfos[i].pColorBlendState->logicOpEnable);
2904
2905 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002906 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002907 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2908 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002909 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002910 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002911
2912 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002913 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2914 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002915 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002916 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002917 ParameterName::IndexVector{i, attachment_index}),
2918 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002919
2920 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002921 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002922 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002923 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002924 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002925 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002926 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002927
2928 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002929 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002930 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002931 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002932 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002933 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002934 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002935
2936 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002937 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002938 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002939 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002941 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002942 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002943
2944 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002945 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002946 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002947 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002948 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002949 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002950 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002951
2952 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002953 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002954 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002955 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002957 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002958 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002959
2960 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002961 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002963 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002965 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002966 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002967
2968 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002969 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002971 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002972 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002973 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002974 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002975 }
2976 }
2977
2978 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002979 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002980 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2981 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2982 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002983 }
2984
2985 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2986 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2987 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002988 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002990 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2991 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002992 }
2993 }
2994 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002996 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
2997 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01002998 if (pCreateInfos[i].basePipelineIndex != -1) {
2999 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003000 skip |=
3001 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003002 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003003 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003004 "and pCreateInfos->basePipelineIndex is not -1.",
3005 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003006 }
3007 }
3008
Petr Kraus9752aae2017-11-24 03:05:50 +01003009 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3010 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003011 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003012 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003013 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003014 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3015 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003016 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003017 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003018 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003019 skip |=
3020 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
3021 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
3022 "index into the pCreateInfos array, of size %d.",
3023 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003024 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003025 }
3026 }
3027
Petr Kraus9752aae2017-11-24 03:05:50 +01003028 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003029 if (!device_extensions.vk_nv_fill_rectangle) {
3030 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3031 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003032 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3033 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3034 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3035 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003036 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3037 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003038 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003039 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003040 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
3041 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3042 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003043 }
3044 } else {
3045 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3046 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3047 (physical_device_features.fillModeNonSolid == false)) {
3048 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003049 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3050 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003051 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
3052 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3053 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003054 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003055 }
Petr Kraus299ba622017-11-24 03:09:03 +01003056
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003057 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003058 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003059 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3060 "The line width state is static (pCreateInfos[%" PRIu32
3061 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3062 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3063 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3064 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003065 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003066 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003067
3068 // Validate no flags not allowed are used
3069 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003070 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
3071 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3072 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3073 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003074 }
3075 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003076 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
3077 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3078 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3079 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003080 }
3081 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3082 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07003083 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3084 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3085 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003086 }
3087 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3088 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07003089 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3090 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3091 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003092 }
3093 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3094 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07003095 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3096 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3097 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003098 }
3099 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3100 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003101 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3102 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3103 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003104 }
3105 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3106 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003107 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3108 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3109 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003110 }
3111 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3112 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003113 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3114 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3115 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003116 }
3117 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3118 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003119 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3120 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3121 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003122 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003123 }
3124 }
3125
3126 return skip;
3127}
3128
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003129bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3130 uint32_t createInfoCount,
3131 const VkComputePipelineCreateInfo *pCreateInfos,
3132 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003133 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003134 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003135 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003136 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003137 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003138 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003139 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003140 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003141 skip |=
3142 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3143 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3144 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3145 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003146 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003147
3148 // Make sure compute stage is selected
3149 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003150 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3151 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3152 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003153 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003154
sfricke-samsungeb549012021-04-16 01:25:51 -07003155 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3156 // Validate no flags not allowed are used
3157 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3158 skip |= LogError(
3159 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3160 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3161 i, flags);
3162 }
3163 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3164 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3165 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3166 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3167 i, flags);
3168 }
3169 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3170 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3171 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3172 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3173 i, flags);
3174 }
3175 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3176 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3177 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3178 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3179 i, flags);
3180 }
3181 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3182 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3183 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3184 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3185 i, flags);
3186 }
3187 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3188 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3189 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3190 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3191 i, flags);
3192 }
3193 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3194 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3195 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3196 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3197 i, flags);
3198 }
3199 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3200 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3201 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3202 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3203 i, flags);
3204 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003205 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3206 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
3207 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3208 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3209 i, flags);
3210 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003211 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3212 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3213 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3214 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3215 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003216 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003218 return skip;
3219}
3220
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003221bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003222 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003223 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003224
3225 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003226 const auto &features = physical_device_features;
3227 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003228
John Zulauf71968502017-10-26 13:51:15 -06003229 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3230 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003231 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3232 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3233 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3234 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003235 }
3236
3237 // Anistropy cannot be enabled in sampler unless enabled as a feature
3238 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003239 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3240 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3241 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003242 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003243 }
John Zulauf71968502017-10-26 13:51:15 -06003244
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003245 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3246 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003247 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3248 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3249 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3250 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003251 }
3252 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003253 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3254 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3255 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3256 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003257 }
3258 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003259 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3260 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3261 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3262 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003263 }
3264 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3265 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3266 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3267 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003268 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3269 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3270 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3271 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3272 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3273 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003274 }
3275 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003276 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3277 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3278 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003279 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003280 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003281 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3282 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3283 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003284 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003285 }
3286
3287 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3288 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003289 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3290 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003291 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003292 if (sampler_reduction != nullptr) {
3293 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3294 skip |= LogError(
3295 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3296 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3297 }
3298 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003299 }
3300
3301 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3302 // valid VkBorderColor value
3303 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3304 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3305 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003306 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3307 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003308 }
3309
John Zulauf275805c2017-10-26 15:34:49 -06003310 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003311 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003312 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3313 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003314 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3315 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3316 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003317 }
3318 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003319
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003320 // Check for valid Lod range
3321 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003322 skip |=
3323 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3324 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003325 }
3326
3327 // Check mipLodBias to device limit
3328 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003329 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3330 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3331 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003332 }
3333
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003334 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003335 if (sampler_conversion != nullptr) {
3336 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3337 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3338 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3339 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003340 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003341 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003342 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3343 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3344 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3345 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3346 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3347 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3348 }
3349 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003350
3351 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3352 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3353 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3354 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3355 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3356 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3357 }
3358 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3359 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3360 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3361 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3362 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3363 }
3364 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3365 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3366 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3367 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3368 pCreateInfo->minLod, pCreateInfo->maxLod);
3369 }
3370 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3371 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3372 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3373 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3374 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3375 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3376 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3377 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3378 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3379 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3380 }
3381 if (pCreateInfo->anisotropyEnable) {
3382 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3383 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3384 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3385 }
3386 if (pCreateInfo->compareEnable) {
3387 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3388 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3389 "pCreateInfo->compareEnable must be VK_FALSE");
3390 }
3391 if (pCreateInfo->unnormalizedCoordinates) {
3392 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3393 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3394 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3395 }
3396 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003397 }
3398
Tony-LunarG7337b312020-04-15 16:40:25 -06003399 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3400 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3401 if (!device_extensions.vk_ext_custom_border_color) {
3402 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3403 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3404 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3405 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003406 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003407 if (!custom_create_info) {
3408 skip |=
3409 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3410 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3411 "struct in pNext chain.\n",
3412 string_VkBorderColor(pCreateInfo->borderColor));
3413 } else {
3414 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3415 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3416 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3417 !FormatIsSampledFloat(custom_create_info->format)))) {
3418 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3419 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3420 "whose type does not match\n",
3421 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3422 ;
3423 }
3424 }
3425 }
3426
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003427 return skip;
3428}
3429
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003430bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3431 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3432 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003433 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003434 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003435
3436 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3437 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3438 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3439 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003440 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3441 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3442 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3443 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3444 ++descriptor_index) {
3445 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003446 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003447 "vkCreateDescriptorSetLayout: required parameter "
3448 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3449 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003450 }
3451 }
3452 }
3453
3454 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3455 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3456 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003457 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3458 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3459 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3460 "values.",
3461 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003462 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003463
3464 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3465 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3466 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3467 skip |=
3468 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3469 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3470 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3471 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3472 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3473 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003474 }
3475 }
3476 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003477 return skip;
3478}
3479
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003480bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3481 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003482 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003483 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3484 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3485 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003486 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3487 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003488}
3489
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003490bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3491 const VkWriteDescriptorSet *pDescriptorWrites,
3492 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003493 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003494
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003495 if (pDescriptorWrites != NULL) {
3496 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3497 // descriptorCount must be greater than 0
3498 if (pDescriptorWrites[i].descriptorCount == 0) {
3499 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003500 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3501 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003502 }
3503
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003504 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3505 if (validateDstSet) {
3506 // dstSet must be a valid VkDescriptorSet handle
3507 skip |= validate_required_handle(vkCallingFunction,
3508 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3509 pDescriptorWrites[i].dstSet);
3510 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003511
3512 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3513 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3514 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3515 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3516 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3517 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3518 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003519 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3520 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003521 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003522 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3523 "%s(): if pDescriptorWrites[%d].descriptorType is "
3524 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3525 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3526 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3527 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003528 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3529 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003530 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3531 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003532 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3533 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003534 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003535 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3536 ParameterName::IndexVector{i, descriptor_index}),
3537 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003538 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003539 }
3540 }
3541 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3542 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3543 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3544 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3545 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3546 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3547 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003548 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003549 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003550 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3551 "%s(): if pDescriptorWrites[%d].descriptorType is "
3552 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3553 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3554 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3555 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003556 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003557 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003558 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003559 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003560 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3561 ++descriptor_index) {
3562 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3563 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3564 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003565 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3566 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003567 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003568 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3569 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003570 }
3571 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003572 }
3573 }
3574 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3575 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003576 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003577 }
3578
3579 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3580 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003581 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003582 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3583 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003584 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003585 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003586 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3587 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3588 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003589 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003590 }
3591 }
3592 }
3593 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3594 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003595 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003596 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3597 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003598 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003599 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003600 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3601 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3602 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003603 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003604 }
3605 }
3606 }
3607 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003608 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3609 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003610 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003611 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003612 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3613 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3614 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3615 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3616 "accelerationStructureCount %d member equals descriptorCount %d.",
3617 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3618 pDescriptorWrites[i].descriptorCount);
3619 }
3620 // further checks only if we have right structtype
3621 if (pnext_struct) {
3622 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3623 skip |= LogError(
3624 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3625 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3626 ".",
3627 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003628 }
sourav parmarbcee7512020-12-28 14:34:49 -08003629 if (pnext_struct->accelerationStructureCount == 0) {
3630 skip |= LogError(device,
3631 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003632 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003633 }
3634 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003635 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003636 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3637 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3638 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3639 skip |= LogError(device,
3640 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3641 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003642 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003643 }
3644 }
3645 }
sourav parmarbcee7512020-12-28 14:34:49 -08003646 }
3647 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003648 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003649 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3650 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3651 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3652 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3653 "accelerationStructureCount %d member equals descriptorCount %d.",
3654 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3655 pDescriptorWrites[i].descriptorCount);
3656 }
3657 // further checks only if we have right structtype
3658 if (pnext_struct) {
3659 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3660 skip |= LogError(
3661 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3662 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3663 ".",
3664 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003665 }
sourav parmarbcee7512020-12-28 14:34:49 -08003666 if (pnext_struct->accelerationStructureCount == 0) {
3667 skip |= LogError(device,
3668 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003669 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003670 }
3671 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003672 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003673 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3674 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3675 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3676 skip |= LogError(device,
3677 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3678 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003679 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003680 }
3681 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003682 }
3683 }
3684 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003685 }
3686 }
3687 return skip;
3688}
3689
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003690bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3691 const VkWriteDescriptorSet *pDescriptorWrites,
3692 uint32_t descriptorCopyCount,
3693 const VkCopyDescriptorSet *pDescriptorCopies) const {
3694 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3695}
3696
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003697bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003698 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003699 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003700 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3701}
3702
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003703bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3704 const VkAllocationCallbacks *pAllocator,
3705 VkRenderPass *pRenderPass) const {
3706 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3707}
3708
Mike Schuchardt2df08912020-12-15 16:28:09 -08003709bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003710 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003711 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003712 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3713}
3714
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003715bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3716 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003717 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003718 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003719
3720 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3721 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3722 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003723 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3724 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003725 return skip;
3726}
3727
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003728bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003729 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003730 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003731
3732 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3733 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003734 bool cb_is_secondary;
3735 {
3736 auto lock = cb_read_lock();
3737 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3738 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003739
Tony-LunarG3c287f62020-12-17 12:39:49 -07003740 if (cb_is_secondary) {
3741 // Implicit VUs
3742 // validate only sType here; pointer has to be validated in core_validation
3743 const bool k_not_required = false;
3744 const char *k_no_vuid = nullptr;
3745 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3746 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003747 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3748 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003749
Tony-LunarG3c287f62020-12-17 12:39:49 -07003750 if (info) {
3751 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003752 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3753 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003754 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003755 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3756 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3757 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3758 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003759
Tony-LunarG3c287f62020-12-17 12:39:49 -07003760 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003761
Tony-LunarG3c287f62020-12-17 12:39:49 -07003762 // Explicit VUs
3763 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003764 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003765 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3766 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3767 cmd_name);
3768 }
3769
3770 if (physical_device_features.inheritedQueries) {
3771 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003772 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3773 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3774 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003775 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003776 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003777 }
3778
3779 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003780 skip |=
3781 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3782 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3783 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3784 } else { // !pipelineStatisticsQuery
3785 skip |=
3786 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3787 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003788 }
3789
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003790 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003791 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003792 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003793 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3794 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3795 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003796 commandBuffer,
3797 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003798 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3799 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3800 }
Petr Kraus139757b2019-08-15 17:19:33 +02003801 }
ziga-lunarg9d019132021-07-19 01:05:31 +02003802
3803 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
3804 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
3805 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
3806 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
3807 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
3808 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
3809 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
3810 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
3811 }
Petr Kraus139757b2019-08-15 17:19:33 +02003812 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003813 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003814 return skip;
3815}
3816
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003817bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003818 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003819 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003820
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003821 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003822 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003823 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3824 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3825 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003826 }
3827 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003828 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3829 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3830 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003831 }
3832 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003833 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003834 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003835 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3836 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3837 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3838 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003839 }
3840 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003841
3842 if (pViewports) {
3843 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3844 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003845 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003846 skip |= manual_PreCallValidateViewport(
3847 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003848 }
3849 }
3850
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003851 return skip;
3852}
3853
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003854bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003855 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003856 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003857
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003858 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003859 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003860 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3861 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3862 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003863 }
3864 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003865 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3866 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3867 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003868 }
3869 } else { // multiViewport enabled
3870 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003871 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003872 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3873 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3874 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3875 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003876 }
3877 }
3878
Petr Kraus6260f0a2018-02-27 21:15:55 +01003879 if (pScissors) {
3880 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3881 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003882
Petr Kraus6260f0a2018-02-27 21:15:55 +01003883 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003884 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3885 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3886 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003887 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003888
Petr Kraus6260f0a2018-02-27 21:15:55 +01003889 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003890 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3891 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3892 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003893 }
3894
3895 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3896 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003897 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3898 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3899 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3900 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003901 }
3902
3903 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3904 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003905 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3906 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3907 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3908 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003909 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003910 }
3911 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003912
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003913 return skip;
3914}
3915
Jeff Bolz5c801d12019-10-09 10:38:45 -05003916bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003917 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003918
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003919 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003920 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3921 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003922 }
3923
3924 return skip;
3925}
3926
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003927bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003928 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003929 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003930
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003931 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003932 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003933 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3934 }
3935 if (drawCount > device_limits.maxDrawIndirectCount) {
3936 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003937 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3938 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003939 }
3940 return skip;
3941}
3942
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003943bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003944 VkDeviceSize offset, uint32_t drawCount,
3945 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003946 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003947 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003948 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3949 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3950 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003951 }
3952 if (drawCount > device_limits.maxDrawIndirectCount) {
3953 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003954 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3955 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003956 }
3957 return skip;
3958}
3959
sfricke-samsungf692b972020-05-02 08:00:45 -07003960bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3961 VkDeviceSize countBufferOffset, bool khr) const {
3962 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003963 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003964 if (offset & 3) {
3965 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003966 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003967 }
3968
3969 if (countBufferOffset & 3) {
3970 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003971 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003972 countBufferOffset);
3973 }
3974 return skip;
3975}
3976
3977bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3978 VkDeviceSize offset, VkBuffer countBuffer,
3979 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3980 uint32_t stride) const {
3981 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3982}
3983
3984bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3985 VkDeviceSize offset, VkBuffer countBuffer,
3986 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3987 uint32_t stride) const {
3988 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3989}
3990
3991bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3992 VkDeviceSize countBufferOffset, bool khr) const {
3993 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003994 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003995 if (offset & 3) {
3996 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003997 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003998 }
3999
4000 if (countBufferOffset & 3) {
4001 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004002 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004003 countBufferOffset);
4004 }
4005 return skip;
4006}
4007
4008bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4009 VkDeviceSize offset, VkBuffer countBuffer,
4010 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4011 uint32_t stride) const {
4012 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4013}
4014
4015bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4016 VkDeviceSize offset, VkBuffer countBuffer,
4017 VkDeviceSize countBufferOffset,
4018 uint32_t maxDrawCount, uint32_t stride) const {
4019 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4020}
4021
Tony-LunarG4490de42021-06-21 15:49:19 -06004022bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4023 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4024 uint32_t firstInstance, uint32_t stride) const {
4025 bool skip = false;
4026 if (stride & 3) {
4027 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4028 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4029 }
4030 if (drawCount && nullptr == pVertexInfo) {
4031 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4032 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4033 "one or more valid instances of VkMultiDrawInfoEXT structures");
4034 }
4035 return skip;
4036}
4037
4038bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4039 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4040 uint32_t instanceCount, uint32_t firstInstance,
4041 uint32_t stride, const int32_t *pVertexOffset) const {
4042 bool skip = false;
4043 if (stride & 3) {
4044 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4045 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4046 }
4047 if (drawCount && nullptr == pIndexInfo) {
4048 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4049 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4050 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4051 }
4052 return skip;
4053}
4054
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004055bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4056 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004057 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004058 bool skip = false;
4059 for (uint32_t rect = 0; rect < rectCount; rect++) {
4060 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004061 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
4062 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004063 }
sfricke-samsung10867682020-04-25 02:20:39 -07004064 if (pRects[rect].rect.extent.width == 0) {
4065 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
4066 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
4067 }
4068 if (pRects[rect].rect.extent.height == 0) {
4069 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
4070 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
4071 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004072 }
4073 return skip;
4074}
4075
Andrew Fobel3abeb992020-01-20 16:33:22 -05004076bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4077 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4078 VkImageFormatProperties2 *pImageFormatProperties,
4079 const char *apiName) const {
4080 bool skip = false;
4081
4082 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004083 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004084 if (image_stencil_struct != nullptr) {
4085 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4086 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4087 // No flags other than the legal attachment bits may be set
4088 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4089 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004090 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4091 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4092 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4093 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4094 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004095 }
4096 }
4097 }
4098 }
4099
4100 return skip;
4101}
4102
4103bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4104 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4105 VkImageFormatProperties2 *pImageFormatProperties) const {
4106 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4107 "vkGetPhysicalDeviceImageFormatProperties2");
4108}
4109
4110bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4111 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4112 VkImageFormatProperties2 *pImageFormatProperties) const {
4113 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4114 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4115}
4116
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004117bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4118 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4119 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4120 bool skip = false;
4121
4122 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4123 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4124 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4125 }
4126
4127 return skip;
4128}
4129
sfricke-samsung3999ef62020-02-09 17:05:59 -08004130bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4131 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4132 bool skip = false;
4133
4134 if (pRegions != nullptr) {
4135 for (uint32_t i = 0; i < regionCount; i++) {
4136 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004137 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4138 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004139 }
4140 }
4141 }
4142 return skip;
4143}
4144
Jeff Leger178b1e52020-10-05 12:22:23 -04004145bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4146 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4147 bool skip = false;
4148
4149 if (pCopyBufferInfo->pRegions != nullptr) {
4150 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4151 if (pCopyBufferInfo->pRegions[i].size == 0) {
4152 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4153 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4154 }
4155 }
4156 }
4157 return skip;
4158}
4159
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004160bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004161 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4162 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004163 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004164
4165 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004166 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4167 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4168 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004169 }
4170
4171 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004172 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4173 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4174 "), must be greater than zero and less than or equal to 65536.",
4175 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004176 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004177 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4178 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4179 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004180 }
4181 return skip;
4182}
4183
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004184bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004185 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004186 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004187
4188 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004189 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4190 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4191 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004192 }
4193
4194 if (size != VK_WHOLE_SIZE) {
4195 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004196 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004197 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4198 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004199 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004200 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4201 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004202 }
4203 }
4204 return skip;
4205}
4206
sfricke-samsunga1d00272021-03-10 21:37:41 -08004207bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004208 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004209
4210 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004211 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4212 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4213 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4214 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004215 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004216 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4217 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4218 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004219 }
4220
4221 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4222 // queueFamilyIndexCount uint32_t values
4223 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004224 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004225 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004226 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004227 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4228 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004229 }
4230 }
4231
Dave Houlton413a6782018-05-22 13:01:54 -06004232 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004233 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004234
sfricke-samsunga1d00272021-03-10 21:37:41 -08004235 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4236 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4237 if (format_list_info) {
4238 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4239 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4240 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4241 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4242 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4243 func_name, viewFormatCount);
4244 }
4245
4246 // Using the first format, compare the rest of the formats against it that they are compatible
4247 for (uint32_t i = 1; i < viewFormatCount; i++) {
4248 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4249 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4250 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4251 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4252 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4253 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4254 string_VkFormat(format_list_info->pViewFormats[i]));
4255 }
4256 }
4257 }
4258
4259 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4260 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4261 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4262 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4263 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4264 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4265 func_name);
4266 } else {
4267 if (format_list_info == nullptr) {
4268 skip |= LogError(
4269 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4270 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4271 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4272 func_name);
4273 } else if (format_list_info->viewFormatCount == 0) {
4274 skip |= LogError(
4275 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4276 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4277 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4278 func_name);
4279 } else {
4280 bool found_base_format = false;
4281 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4282 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4283 found_base_format = true;
4284 break;
4285 }
4286 }
4287 if (!found_base_format) {
4288 skip |=
4289 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4290 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4291 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4292 "pCreateInfo->imageFormat.",
4293 func_name);
4294 }
4295 }
4296 }
4297 }
4298 }
4299 return skip;
4300}
4301
4302bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4303 const VkAllocationCallbacks *pAllocator,
4304 VkSwapchainKHR *pSwapchain) const {
4305 bool skip = false;
4306 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4307 return skip;
4308}
4309
4310bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4311 const VkSwapchainCreateInfoKHR *pCreateInfos,
4312 const VkAllocationCallbacks *pAllocator,
4313 VkSwapchainKHR *pSwapchains) const {
4314 bool skip = false;
4315 if (pCreateInfos) {
4316 for (uint32_t i = 0; i < swapchainCount; i++) {
4317 std::stringstream func_name;
4318 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4319 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4320 }
4321 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004322 return skip;
4323}
4324
Jeff Bolz5c801d12019-10-09 10:38:45 -05004325bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004326 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004327
4328 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004329 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004330 if (present_regions) {
4331 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004332 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004333 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4334 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004335 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004336 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4337 "extension swapchainCount is %i. These values must be equal.",
4338 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004339 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004340 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004341 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4342 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004343 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4344 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4345 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004346 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004347 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004348 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004349 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004350 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004351 }
4352 }
4353
4354 return skip;
4355}
4356
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004357bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4358 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4359 const VkAllocationCallbacks *pAllocator,
4360 VkDisplayModeKHR *pMode) const {
4361 bool skip = false;
4362
4363 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4364 if (display_mode_parameters.visibleRegion.width == 0) {
4365 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4366 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4367 }
4368 if (display_mode_parameters.visibleRegion.height == 0) {
4369 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4370 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4371 }
4372 if (display_mode_parameters.refreshRate == 0) {
4373 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4374 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4375 }
4376
4377 return skip;
4378}
4379
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004380#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004381bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4382 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4383 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004384 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004385 bool skip = false;
4386
4387 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004388 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4389 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004390 }
4391
4392 return skip;
4393}
4394#endif // VK_USE_PLATFORM_WIN32_KHR
4395
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004396bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004397 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004398 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004399 bool skip = false;
4400
4401 if (pCreateInfo) {
4402 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004403 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4404 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004405 }
4406
4407 if (pCreateInfo->pPoolSizes) {
4408 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4409 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004410 skip |= LogError(
4411 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004412 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004413 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004414 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4415 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004416 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4417 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4418 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4419 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4420 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004421 }
Petr Krausc8655be2017-09-27 18:56:51 +02004422 }
4423 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004424
4425 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4426 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4427 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4428 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4429 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4430 }
Petr Krausc8655be2017-09-27 18:56:51 +02004431 }
4432
4433 return skip;
4434}
4435
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004436bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004437 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004438 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004440 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004441 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004442 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4443 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4444 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004445 }
4446
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004447 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004448 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004449 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4450 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4451 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004452 }
4453
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004454 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004455 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004456 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4457 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4458 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004459 }
4460
4461 return skip;
4462}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004463
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004464bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004465 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004466 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004467
4468 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004469 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4470 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004471 }
4472 return skip;
4473}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004474
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004475bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4476 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004477 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004478 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004479
4480 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004481 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004482 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004483 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4484 "vkCmdDispatch(): baseGroupX (%" PRIu32
4485 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4486 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004487 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004488 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4489 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4490 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4491 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004492 }
4493
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004494 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004495 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004496 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4497 "vkCmdDispatch(): baseGroupY (%" PRIu32
4498 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4499 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004500 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004501 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4502 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4503 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4504 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004505 }
4506
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004507 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004508 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004509 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4510 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4511 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4512 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004513 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004514 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4515 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4516 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4517 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004518 }
4519
4520 return skip;
4521}
4522
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004523bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4524 VkPipelineBindPoint pipelineBindPoint,
4525 VkPipelineLayout layout, uint32_t set,
4526 uint32_t descriptorWriteCount,
4527 const VkWriteDescriptorSet *pDescriptorWrites) const {
4528 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4529}
4530
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004531bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4532 uint32_t firstExclusiveScissor,
4533 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004534 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004535 bool skip = false;
4536
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004537 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004538 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004539 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004540 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4541 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4542 ") is not 0.",
4543 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004544 }
4545 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004546 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004547 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4548 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4549 ") is not 1.",
4550 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004551 }
4552 } else { // multiViewport enabled
4553 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004554 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004555 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4556 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4557 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4558 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004559 }
4560 }
4561
Jeff Bolz3e71f782018-08-29 23:15:45 -05004562 if (pExclusiveScissors) {
4563 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4564 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4565
4566 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004567 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4568 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4569 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004570 }
4571
4572 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004573 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4574 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4575 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004576 }
4577
4578 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4579 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004580 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4581 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4582 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4583 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004584 }
4585
4586 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4587 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004588 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4589 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4590 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4591 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004592 }
4593 }
4594 }
4595
4596 return skip;
4597}
4598
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004599bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4600 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004601 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004602 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004603 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4604 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4605 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4606 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4607 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4608 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004609 }
4610
4611 return skip;
4612}
4613
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004614bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4615 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004616 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004617 bool skip = false;
4618
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004619 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004620 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004621 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004622 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4623 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4624 ") is not 0.",
4625 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004626 }
4627 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004628 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004629 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4630 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4631 ") is not 1.",
4632 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004633 }
4634 }
4635
Jeff Bolz9af91c52018-09-01 21:53:57 -05004636 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004637 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004638 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4639 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4640 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4641 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004642 }
4643
4644 return skip;
4645}
4646
Jeff Bolz5c801d12019-10-09 10:38:45 -05004647bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4648 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4649 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004650 bool skip = false;
4651
Dave Houlton142c4cb2018-10-17 15:04:41 -06004652 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004653 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4654 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4655 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004656 }
4657
4658 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004659 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004660 }
4661
4662 return skip;
4663}
4664
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004665bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004666 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004667 bool skip = false;
4668
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004669 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004670 skip |= LogError(
4671 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004672 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4673 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004674 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004675 }
4676
4677 return skip;
4678}
4679
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004680bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4681 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004682 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004683 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004684 static const int condition_multiples = 0b0011;
4685 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004686 skip |= LogError(
4687 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004688 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004689 }
Lockee1c22882019-06-10 16:02:54 -06004690 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004691 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4692 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4693 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4694 stride);
Lockee1c22882019-06-10 16:02:54 -06004695 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004696 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004697 skip |= LogError(
4698 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4699 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004700 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004701 if (drawCount > device_limits.maxDrawIndirectCount) {
4702 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004703 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4704 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004705 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004706 return skip;
4707}
4708
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004709bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4710 VkDeviceSize offset, VkBuffer countBuffer,
4711 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004712 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004713 bool skip = false;
4714
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004715 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004716 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4717 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4718 "), is not a multiple of 4.",
4719 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004720 }
4721
4722 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004723 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4724 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4725 "), is not a multiple of 4.",
4726 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004727 }
4728
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004729 return skip;
4730}
4731
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004732bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004733 const VkAllocationCallbacks *pAllocator,
4734 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004735 bool skip = false;
4736
4737 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4738 if (pCreateInfo != nullptr) {
4739 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4740 // VkQueryPipelineStatisticFlagBits values
4741 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4742 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004743 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4744 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4745 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4746 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004747 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004748 if (pCreateInfo->queryCount == 0) {
4749 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4750 "vkCreateQueryPool(): queryCount must be greater than zero.");
4751 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004752 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004753 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004754}
4755
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004756bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4757 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004758 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004759 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4760 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004761}
4762
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004763void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004764 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4765 VkResult result) {
4766 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004767 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004768}
4769
Mike Schuchardt2df08912020-12-15 16:28:09 -08004770void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004771 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4772 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004773 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004774 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004775 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004776}
4777
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004778void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4779 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004780 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004781 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004782 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004783}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004784
Tony-LunarG3c287f62020-12-17 12:39:49 -07004785void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004786 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004787 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4788 auto lock = cb_write_lock();
4789 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004790 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004791 }
4792 }
4793}
4794
4795void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004796 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004797 auto lock = cb_write_lock();
4798 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4799 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4800 }
4801}
4802
4803void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004804 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004805 auto lock = cb_write_lock();
4806 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4807 if (item->second == commandPool) {
4808 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004809 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004810 ++item;
4811 }
4812 }
4813}
4814
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004815bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004816 const VkAllocationCallbacks *pAllocator,
4817 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004818 bool skip = false;
4819
4820 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004821 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004822 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004823 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4824 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004825 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004826
4827 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004828 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004829 if (flags_info) {
4830 flags = flags_info->flags;
4831 }
4832
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004833 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004834 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004835 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004836 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4837 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004838 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004839 }
4840
4841#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004842 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004843#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004844 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4845 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004846#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004847 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004848#endif
4849
4850 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004851 skip |= LogError(
4852 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004853 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4854 }
4855 if (
4856#ifdef VK_USE_PLATFORM_WIN32_KHR
4857 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4858#endif
4859 (import_memory_fd && import_memory_fd->handleType) ||
4860#ifdef VK_USE_PLATFORM_ANDROID_KHR
4861 (import_memory_ahb && import_memory_ahb->buffer) ||
4862#endif
4863 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004864 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4865 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004866 }
4867 }
4868
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02004869 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
4870 if (export_memory) {
4871 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
4872 if (export_memory_nv) {
4873 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4874 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4875 "VkExportMemoryAllocateInfoNV");
4876 }
4877#ifdef VK_USE_PLATFORM_WIN32_KHR
4878 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
4879 if (export_memory_win32_nv) {
4880 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4881 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4882 "VkExportMemoryWin32HandleInfoNV");
4883 }
4884#endif
4885 }
4886
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004887 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004888 VkBool32 capture_replay = false;
4889 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004890 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004891 if (vulkan_12_features) {
4892 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4893 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4894 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004895 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004896 if (bda_features) {
4897 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4898 buffer_device_address = bda_features->bufferDeviceAddress;
4899 }
4900 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004901 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004902 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004903 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004904 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004905 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004906 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004907 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004908 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004909 }
4910 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004911 }
4912 return skip;
4913}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004914
Jason Macnak192fa0e2019-07-26 15:07:16 -07004915bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004916 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004917 bool skip = false;
4918
4919 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4920 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4921 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004922 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004923 } else {
4924 uint32_t vertex_component_size = 0;
4925 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4926 vertex_component_size = 4;
4927 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4928 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4929 vertex_component_size = 2;
4930 }
4931 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004932 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004933 }
4934 }
4935
4936 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4937 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004938 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004939 } else {
4940 uint32_t index_element_size = 0;
4941 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4942 index_element_size = 4;
4943 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4944 index_element_size = 2;
4945 }
4946 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004947 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004948 }
4949 }
4950 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4951 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004952 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004953 }
4954 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004955 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004956 }
4957 }
4958
4959 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004960 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004961 }
4962
4963 return skip;
4964}
4965
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004966bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4967 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004968 bool skip = false;
4969
4970 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004971 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004972 }
4973 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004974 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004975 }
4976
4977 return skip;
4978}
4979
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004980bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4981 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004982 bool skip = false;
4983 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004984 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004985 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004986 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004987 }
4988 return skip;
4989}
4990
4991bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004992 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004993 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004994 bool skip = false;
4995 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004996 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4997 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4998 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004999 }
5000 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005001 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5002 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5003 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005004 }
5005 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5006 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005007 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5008 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5009 "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 -07005010 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005011 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005012 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005013 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5014 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005015 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5016 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005017 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005018 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005019 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5020 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5021 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005022 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005023 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005024 uint64_t total_triangle_count = 0;
5025 for (uint32_t i = 0; i < info.geometryCount; i++) {
5026 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005027
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005028 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005029
Jason Macnak5c954952019-07-09 15:46:12 -07005030 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5031 continue;
5032 }
5033 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5034 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005035 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005036 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5037 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5038 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005039 }
5040 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005041 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5042 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5043 for (uint32_t i = 1; i < info.geometryCount; i++) {
5044 const VkGeometryNV &geometry = info.pGeometries[i];
5045 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005046 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005047 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
5048 "info.pGeometries[0].geometryType.",
5049 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005050 }
5051 }
5052 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005053 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5054 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5055 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5056 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5057 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5058 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5059 }
5060 }
5061 skip |=
5062 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005063 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005064 return skip;
5065}
5066
Ricardo Garciaa4935972019-02-21 17:43:18 +01005067bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5068 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005069 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005070 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005071 if (pCreateInfo) {
5072 if ((pCreateInfo->compactedSize != 0) &&
5073 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005074 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5075 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5076 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5077 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005078 }
Jason Macnak5c954952019-07-09 15:46:12 -07005079
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005080 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005081 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005082 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005083 return skip;
5084}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005085
Jeff Bolz5c801d12019-10-09 10:38:45 -05005086bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5087 const VkAccelerationStructureInfoNV *pInfo,
5088 VkBuffer instanceData, VkDeviceSize instanceOffset,
5089 VkBool32 update, VkAccelerationStructureNV dst,
5090 VkAccelerationStructureNV src, VkBuffer scratch,
5091 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005092 bool skip = false;
5093
5094 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005095 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005096 }
5097
5098 return skip;
5099}
5100
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005101bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5102 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5103 VkAccelerationStructureKHR *pAccelerationStructure) const {
5104 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005105 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005106 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005107 if (!acceleration_structure_features ||
5108 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5109 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5110 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5111 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005112 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005113 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5114 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005115 (acceleration_structure_features &&
5116 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005117 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005118 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5119 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5120 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5121 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005122 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005123 if (pCreateInfo->deviceAddress &&
5124 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5125 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5126 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5127 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5128 }
5129 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5130 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005131 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005132 }
sourav parmar83c31b12020-05-06 12:30:54 -07005133 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005134 return skip;
5135}
5136
Jason Macnak5c954952019-07-09 15:46:12 -07005137bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5138 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005139 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005140 bool skip = false;
5141 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005142 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5143 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005144 }
5145 return skip;
5146}
5147
sourav parmarcd5fb182020-07-17 12:58:44 -07005148bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5149 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5150 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5151 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005152 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005153 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
5154 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005155 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005156 }
5157 return skip;
5158}
5159
Peter Chen85366392019-05-14 15:20:11 -04005160bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5161 uint32_t createInfoCount,
5162 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5163 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005164 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005165 bool skip = false;
5166
5167 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005168 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005169 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005170 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005171 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5172 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5173 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5174 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005175 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005176
5177 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005178 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005179 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5180 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5181 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5182 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5183 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5184 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5185 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5186 }
5187 }
5188
sourav parmarf4a78252020-04-10 13:04:21 -07005189 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5190 skip |=
5191 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5192 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5193 }
5194 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5195 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5196 skip |=
5197 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5198 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5199 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5200 }
5201 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5202 if (pCreateInfos[i].basePipelineIndex != -1) {
5203 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5204 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5205 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5206 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5207 "and pCreateInfos->basePipelineIndex is not -1.");
5208 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005209 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005210 skip |=
5211 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5212 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5213 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5214 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5215 "that element.");
5216 }
sourav parmarf4a78252020-04-10 13:04:21 -07005217 }
5218 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005219 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005220 skip |=
5221 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5222 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5223 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5224 "commands pCreateInfos parameter.");
5225 }
5226 } else {
5227 if (pCreateInfos[i].basePipelineIndex != -1) {
5228 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5229 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5230 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5231 }
5232 }
5233 }
5234 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5235 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5236 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5237 }
5238 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5239 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5240 "vkCreateRayTracingPipelinesNV: flags must not include "
5241 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5242 }
5243 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5244 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5245 "vkCreateRayTracingPipelinesNV: flags must not include "
5246 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5247 }
5248 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5249 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5250 "vkCreateRayTracingPipelinesNV: flags must not include "
5251 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5252 }
5253 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5254 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5255 "vkCreateRayTracingPipelinesNV: flags must not include "
5256 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5257 }
5258 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5259 skip |= LogError(
5260 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5261 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5262 }
5263 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5264 skip |= LogError(
5265 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5266 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5267 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005268 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5269 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5270 "vkCreateRayTracingPipelinesNV: flags must not include "
5271 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5272 }
5273 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5274 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5275 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5276 }
Peter Chen85366392019-05-14 15:20:11 -04005277 }
5278
5279 return skip;
5280}
5281
sourav parmarcd5fb182020-07-17 12:58:44 -07005282bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5283 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5284 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005285 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005286 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005287 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5288 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5289 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005290 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005291 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005292 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5293 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5294 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5295 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5296 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5297 }
5298 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5299 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5300 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5301 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5302 }
5303 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005304 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005305 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5306 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005307 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5308 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5309 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005310 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5311 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5312 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005313 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005314 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005315 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5316 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5317 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5318 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005319 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005320 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5321 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5322 }
5323 }
sourav parmarf4a78252020-04-10 13:04:21 -07005324 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005325 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5326 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005327 }
5328 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005329 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005330 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005331 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5332 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005333 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005334 }
5335 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5336 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5337 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005338 }
5339 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5340 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5341 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5342 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5343 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5344 skip |= LogError(
5345 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005346 "vkCreateRayTracingPipelinesKHR: If flags includes "
5347 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005348 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5349 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5350 "must not be VK_SHADER_UNUSED_KHR");
5351 }
5352 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5353 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5354 skip |= LogError(
5355 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005356 "vkCreateRayTracingPipelinesKHR: If flags includes "
5357 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005358 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5359 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5360 "element must not be VK_SHADER_UNUSED_KHR");
5361 }
5362 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005363 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5364 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5365 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5366 skip |= LogError(
5367 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5368 "vkCreateRayTracingPipelinesKHR: If "
5369 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5370 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5371 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5372 }
5373 }
sourav parmarf4a78252020-04-10 13:04:21 -07005374 }
5375 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5376 if (pCreateInfos[i].basePipelineIndex != -1) {
5377 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5378 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005379 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005380 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5381 "and pCreateInfos->basePipelineIndex is not -1.");
5382 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005383 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005384 skip |=
5385 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5386 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5387 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5388 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5389 "element.");
5390 }
sourav parmarf4a78252020-04-10 13:04:21 -07005391 }
5392 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005393 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005394 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005395 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005396 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5397 "commands pCreateInfos parameter %d.",
5398 pCreateInfos[i].basePipelineIndex, createInfoCount);
5399 }
5400 } else {
5401 if (pCreateInfos[i].basePipelineIndex != -1) {
5402 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005403 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005404 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5405 }
5406 }
5407 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005408 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5409 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5410 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5411 "vkCreateRayTracingPipelinesKHR: If flags includes "
5412 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5413 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005414 }
5415 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5416 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5417 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5418 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5419 "pLibraryInfo and pLibraryInterface must be NULL.");
5420 }
5421 if (pCreateInfos[i].pLibraryInfo) {
5422 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5423 if (pCreateInfos[i].stageCount == 0) {
5424 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5425 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5426 "stageCount must not be 0.");
5427 }
5428 if (pCreateInfos[i].groupCount == 0) {
5429 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5430 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5431 "groupCount must not be 0.");
5432 }
5433 } else {
5434 if (pCreateInfos[i].pLibraryInterface == NULL) {
5435 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5436 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5437 "is greater than 0, its "
5438 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005439 }
5440 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005441 }
5442 if (pCreateInfos[i].pLibraryInterface) {
5443 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5444 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5445 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5446 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5447 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5448 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005449 }
5450 if (deferredOperation != VK_NULL_HANDLE) {
5451 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5452 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5453 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5454 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005455 }
5456 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005457 }
5458
5459 return skip;
5460}
5461
Mike Schuchardt21638df2019-03-16 10:52:02 -07005462#ifdef VK_USE_PLATFORM_WIN32_KHR
5463bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5464 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005465 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005466 bool skip = false;
5467 if (!device_extensions.vk_khr_swapchain)
5468 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005469 if (!device_extensions.vk_khr_get_surface_capabilities2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005470 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5471 if (!device_extensions.vk_khr_surface)
5472 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005473 if (!device_extensions.vk_khr_get_physical_device_properties2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005474 skip |=
5475 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5476 if (!device_extensions.vk_ext_full_screen_exclusive)
5477 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5478 skip |= validate_struct_type(
5479 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5480 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5481 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5482 if (pSurfaceInfo != NULL) {
5483 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5484 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5485 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5486
5487 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5488 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5489 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5490 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005491 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5492 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005493
5494 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5495 }
5496 return skip;
5497}
5498#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005499
5500bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5501 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005502 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005503 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5504 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005505 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005506 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5507 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5508 }
5509 return skip;
5510}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005511
5512bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005513 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005514 bool skip = false;
5515
5516 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005517 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5518 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005519 }
5520
5521 return skip;
5522}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005523
5524bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005525 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005526 bool skip = false;
5527
5528 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005529 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5530 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005531 }
5532
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005533 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005534 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005535 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5536 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005537 }
5538
5539 return skip;
5540}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005541
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005542bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5543 uint32_t bindingCount, const VkBuffer *pBuffers,
5544 const VkDeviceSize *pOffsets) const {
5545 bool skip = false;
5546 if (firstBinding > device_limits.maxVertexInputBindings) {
5547 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5548 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5549 device_limits.maxVertexInputBindings);
5550 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5551 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5552 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5553 "maxVertexInputBindings (%u)",
5554 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5555 }
5556
Jeff Bolz165818a2020-05-08 11:19:03 -05005557 for (uint32_t i = 0; i < bindingCount; ++i) {
5558 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005559 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005560 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5561 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5562 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5563 } else {
5564 if (pOffsets[i] != 0) {
5565 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5566 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5567 }
5568 }
5569 }
5570 }
5571
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005572 return skip;
5573}
5574
Mark Lobodzinski84988402019-09-11 15:27:30 -06005575bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005576 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005577 bool skip = false;
5578 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005579 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5580 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005581 }
5582 return skip;
5583}
5584
5585bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005586 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005587 bool skip = false;
5588 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005589 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5590 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005591 }
5592 return skip;
5593}
Petr Kraus3d720392019-11-13 02:52:39 +01005594
5595bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5596 VkSemaphore semaphore, VkFence fence,
5597 uint32_t *pImageIndex) const {
5598 bool skip = false;
5599
5600 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005601 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5602 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005603 }
5604
5605 return skip;
5606}
5607
5608bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5609 uint32_t *pImageIndex) const {
5610 bool skip = false;
5611
5612 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005613 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5614 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005615 }
5616
5617 return skip;
5618}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005619
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005620bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5621 uint32_t firstBinding, uint32_t bindingCount,
5622 const VkBuffer *pBuffers,
5623 const VkDeviceSize *pOffsets,
5624 const VkDeviceSize *pSizes) const {
5625 bool skip = false;
5626
5627 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5628 for (uint32_t i = 0; i < bindingCount; ++i) {
5629 if (pOffsets[i] & 3) {
5630 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5631 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5632 }
5633 }
5634
5635 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5636 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5637 "%s: The firstBinding(%" PRIu32
5638 ") index is greater than or equal to "
5639 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5640 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5641 }
5642
5643 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5644 skip |=
5645 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5646 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5647 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5648 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5649 }
5650
5651 for (uint32_t i = 0; i < bindingCount; ++i) {
5652 // pSizes is optional and may be nullptr.
5653 if (pSizes != nullptr) {
5654 if (pSizes[i] != VK_WHOLE_SIZE &&
5655 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5656 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5657 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5658 ") is not VK_WHOLE_SIZE and is greater than "
5659 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5660 cmd_name, i, pSizes[i]);
5661 }
5662 }
5663 }
5664
5665 return skip;
5666}
5667
5668bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5669 uint32_t firstCounterBuffer,
5670 uint32_t counterBufferCount,
5671 const VkBuffer *pCounterBuffers,
5672 const VkDeviceSize *pCounterBufferOffsets) const {
5673 bool skip = false;
5674
5675 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5676 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5677 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5678 "%s: The firstCounterBuffer(%" PRIu32
5679 ") index is greater than or equal to "
5680 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5681 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5682 }
5683
5684 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5685 skip |=
5686 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5687 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5688 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5689 cmd_name, firstCounterBuffer, counterBufferCount,
5690 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5691 }
5692
5693 return skip;
5694}
5695
5696bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5697 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5698 const VkBuffer *pCounterBuffers,
5699 const VkDeviceSize *pCounterBufferOffsets) const {
5700 bool skip = false;
5701
5702 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5703 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5704 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5705 "%s: The firstCounterBuffer(%" PRIu32
5706 ") index is greater than or equal to "
5707 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5708 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5709 }
5710
5711 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5712 skip |=
5713 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5714 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5715 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5716 cmd_name, firstCounterBuffer, counterBufferCount,
5717 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5718 }
5719
5720 return skip;
5721}
5722
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005723bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5724 uint32_t firstInstance, VkBuffer counterBuffer,
5725 VkDeviceSize counterBufferOffset,
5726 uint32_t counterOffset, uint32_t vertexStride) const {
5727 bool skip = false;
5728
5729 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005730 skip |= LogError(
5731 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005732 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5733 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5734 }
5735
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005736 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005737 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005738 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005739 }
5740
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005741 return skip;
5742}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005743
5744bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5745 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5746 const VkAllocationCallbacks *pAllocator,
5747 VkSamplerYcbcrConversion *pYcbcrConversion,
5748 const char *apiName) const {
5749 bool skip = false;
5750
5751 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005752 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005753 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005754 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005755 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5756 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005757 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005758 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005759 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005760
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005761#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005762 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005763 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005764#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005765 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005766#endif
5767
sfricke-samsung1a72f942020-07-25 12:09:18 -07005768 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005769
5770 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005771 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005772 const VkComponentMapping components = pCreateInfo->components;
5773 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5774 if (FormatIsXChromaSubsampled(format) == true) {
5775 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5776 skip |=
5777 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005778 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5779 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005780 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005781 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005782
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005783 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5784 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5785 skip |= LogError(
5786 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5787 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5788 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5789 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5790 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005791
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005792 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5793 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5794 skip |=
5795 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005796 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5797 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005798 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005799 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005800
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005801 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5802 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5803 skip |=
5804 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005805 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5806 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005807 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005808 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005809
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005810 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005811 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5812 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5813 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005814 skip |=
5815 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005816 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5817 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005818 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5819 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005820 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005821 }
5822
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005823 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5824 // Checks same VU multiple ways in order to give a more useful error message
5825 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5826 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5827 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5828 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5829 skip |= LogError(
5830 device, vuid,
5831 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5832 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5833 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5834 string_VkComponentSwizzle(components.b));
5835 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005836
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005837 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5838 // 4 channel format = no issue
5839 // 3 = no [a]
5840 // 2 = no [b,a]
5841 // 1 = no [g,b,a]
5842 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5843 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5844
5845 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5846 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5847 skip |= LogError(device, vuid,
5848 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5849 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5850 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5851 string_VkComponentSwizzle(components.b));
5852 } else if ((channels < 3) &&
5853 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5854 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5855 skip |= LogError(device, vuid,
5856 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5857 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5858 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5859 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5860 string_VkComponentSwizzle(components.b));
5861 } else if ((channels < 2) &&
5862 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5863 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5864 skip |= LogError(device, vuid,
5865 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5866 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5867 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5868 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5869 string_VkComponentSwizzle(components.b));
5870 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005871 }
5872 }
5873
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005874 return skip;
5875}
5876
5877bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5878 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5879 const VkAllocationCallbacks *pAllocator,
5880 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5881 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5882 "vkCreateSamplerYcbcrConversion");
5883}
5884
5885bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5886 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5887 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5888 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5889 "vkCreateSamplerYcbcrConversionKHR");
5890}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005891
5892bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5893 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5894 bool skip = false;
5895 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5896 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5897
5898 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005899 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5900 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5901 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5902 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5903 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005904 }
5905 return skip;
5906}
sourav parmara96ab1a2020-04-25 16:28:23 -07005907
5908bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005909 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005910 bool skip = false;
5911 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5912 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5913 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5914 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005915 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005916 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5917 skip |= LogError(
5918 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5919 "vkCopyAccelerationStructureToMemoryKHR: The "
5920 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5921 }
5922 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5923 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5924 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5925 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5926 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5927 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005928 return skip;
5929}
5930
5931bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5932 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5933 bool skip = false;
5934 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5935 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5936 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5937 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5938 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005939 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5940 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005941 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07005942 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005943 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005944 return skip;
5945}
5946
5947bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5948 const char *api_name) const {
5949 bool skip = false;
5950 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5951 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5952 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5953 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5954 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5955 api_name);
5956 }
5957 return skip;
5958}
5959
5960bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005961 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005962 bool skip = false;
5963 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005964 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005965 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005966 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005967 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5968 "vkCopyAccelerationStructureKHR: The "
5969 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005970 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005971 return skip;
5972}
5973
5974bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5975 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5976 bool skip = false;
5977 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5978 return skip;
5979}
5980
5981bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005982 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005983 bool skip = false;
5984 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005985 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005986 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5987 }
5988 return skip;
5989}
5990
5991bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005992 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005993 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005994 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005995 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005996 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5997 skip |= LogError(
5998 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5999 "vkCopyMemoryToAccelerationStructureKHR: The "
6000 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006001 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006002 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6003 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006004 return skip;
6005}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006006
sourav parmara96ab1a2020-04-25 16:28:23 -07006007bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6008 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6009 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006010 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006011 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6012 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006013 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006014 pInfo->src.deviceAddress);
6015 }
sourav parmar83c31b12020-05-06 12:30:54 -07006016 return skip;
6017}
6018bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6019 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6020 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6021 bool skip = false;
6022 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6023 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6024 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6025 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6026 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6027 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6028 }
6029 return skip;
6030}
6031bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6032 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6033 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6034 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006035 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006036 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6037 skip |= LogError(
6038 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6039 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6040 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6041 }
sourav parmar83c31b12020-05-06 12:30:54 -07006042 if (dataSize < accelerationStructureCount * stride) {
6043 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6044 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
6045 "accelerationStructureCount (%d) *stride(%zu).",
6046 dataSize, accelerationStructureCount, stride);
6047 }
6048 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6049 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6050 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6051 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6052 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6053 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6054 }
6055 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6056 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6057 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6058 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6059 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6060 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6061 stride);
6062 }
6063 }
6064 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6065 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6066 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6067 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6068 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6069 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6070 stride);
6071 }
6072 }
sourav parmar83c31b12020-05-06 12:30:54 -07006073 return skip;
6074}
6075bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6076 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6077 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006078 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006079 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6080 skip |= LogError(
6081 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6082 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6083 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006084 }
6085 return skip;
6086}
6087
6088bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006089 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6090 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6091 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6092 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006093 uint32_t width, uint32_t height, uint32_t depth) const {
6094 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006095 // RayGen
6096 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6097 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6098 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006099 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006100 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6101 0) {
6102 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6103 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6104 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6105 }
6106 // Callable
6107 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6108 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6109 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6110 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006111 }
6112 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6113 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6114 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006115 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6116 }
6117 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6118 0) {
6119 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6120 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6121 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006122 }
6123 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006124 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6125 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6126 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6127 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006128 }
6129 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6130 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006131 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6132 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006133 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006134 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6135 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6136 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6137 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6138 }
sourav parmar83c31b12020-05-06 12:30:54 -07006139 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006140 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6141 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6142 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6143 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006144 }
6145 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6146 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6147 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006148 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6149 }
6150 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6151 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6152 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6153 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6154 }
6155 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6156 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6157 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6158 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6159 }
6160 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6161 skip |=
6162 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6163 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6164 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006165 }
6166
sourav parmarcd5fb182020-07-17 12:58:44 -07006167 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6168 skip |=
6169 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6170 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6171 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6172 }
6173
6174 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6175 skip |=
6176 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6177 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6178 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006179 }
6180 return skip;
6181}
6182
sourav parmarcd5fb182020-07-17 12:58:44 -07006183bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6184 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6185 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6186 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006187 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006188 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006189 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6190 skip |= LogError(
6191 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6192 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6193 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006194 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006195 // RayGen
6196 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6197 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6198 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006199 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006200 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6201 0) {
6202 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6203 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6204 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6205 }
6206 // Callabe
6207 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6208 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6209 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6210 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006211 }
6212 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6213 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006214 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6215 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6216 }
6217 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6218 0) {
6219 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6220 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6221 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006222 }
6223 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006224 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6225 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6226 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6227 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006228 }
6229 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6230 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006231 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6232 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006233 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006234 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6235 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6236 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6237 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6238 }
sourav parmar83c31b12020-05-06 12:30:54 -07006239 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006240 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6241 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6242 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6243 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006244 }
6245 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6246 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006247 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6248 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6249 }
6250 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6251 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6252 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6253 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006254 }
6255
sourav parmarcd5fb182020-07-17 12:58:44 -07006256 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6257 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6258 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006259 }
6260 return skip;
6261}
6262bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6263 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6264 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6265 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6266 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6267 uint32_t width, uint32_t height, uint32_t depth) const {
6268 bool skip = false;
6269 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6270 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6271 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6272 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6273 }
6274 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6275 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6276 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6277 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6278 }
6279 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6280 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6281 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6282 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6283 }
6284
6285 // hitShader
6286 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6287 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6288 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6289 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6290 }
6291 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6292 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6293 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6294 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6295 }
6296 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6297 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6298 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6299 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6300 }
6301
6302 // missShader
6303 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6304 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6305 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6306 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6307 }
6308 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6309 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6310 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6311 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6312 }
6313 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6314 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6315 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6316 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6317 }
6318
6319 // raygenShader
6320 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6321 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6322 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006323 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6324 }
6325 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6326 skip |=
6327 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6328 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6329 }
6330 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6331 skip |=
6332 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6333 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6334 }
6335 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6336 skip |=
6337 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6338 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006339 }
6340 return skip;
6341}
6342
sourav parmar83c31b12020-05-06 12:30:54 -07006343bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006344 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6345 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006346 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006347 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6348 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006349 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6350 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006351 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006352 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6353 }
6354 return skip;
6355}
6356
Piers Daniell39842ee2020-07-10 16:42:33 -06006357bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6358 const VkViewport *pViewports) const {
6359 bool skip = false;
6360
6361 if (!physical_device_features.multiViewport) {
6362 if (viewportCount != 1) {
6363 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6364 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6365 ") is not 1.",
6366 viewportCount);
6367 }
6368 } else { // multiViewport enabled
6369 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6370 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6371 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6372 ") must "
6373 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6374 viewportCount, device_limits.maxViewports);
6375 }
6376 }
6377
6378 if (pViewports) {
6379 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6380 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6381 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6382 skip |= manual_PreCallValidateViewport(
6383 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6384 }
6385 }
6386
6387 return skip;
6388}
6389
6390bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6391 const VkRect2D *pScissors) const {
6392 bool skip = false;
6393
6394 if (!physical_device_features.multiViewport) {
6395 if (scissorCount != 1) {
6396 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6397 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6398 ") must "
6399 "be 1 when the multiViewport feature is disabled.",
6400 scissorCount);
6401 }
6402 } else { // multiViewport enabled
6403 if (scissorCount == 0) {
6404 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6405 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6406 ") must "
6407 "be great than zero.",
6408 scissorCount);
6409 } else if (scissorCount > device_limits.maxViewports) {
6410 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6411 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6412 ") must "
6413 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6414 scissorCount, device_limits.maxViewports);
6415 }
6416 }
6417
6418 if (pScissors) {
6419 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6420 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6421
6422 if (scissor.offset.x < 0) {
6423 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6424 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6425 scissor.offset.x);
6426 }
6427
6428 if (scissor.offset.y < 0) {
6429 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6430 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6431 scissor.offset.y);
6432 }
6433
6434 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6435 if (x_sum > INT32_MAX) {
6436 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6437 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6438 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6439 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6440 }
6441
6442 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6443 if (y_sum > INT32_MAX) {
6444 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6445 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6446 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6447 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6448 }
6449 }
6450 }
6451
6452 return skip;
6453}
6454
6455bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6456 uint32_t bindingCount, const VkBuffer *pBuffers,
6457 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6458 const VkDeviceSize *pStrides) const {
6459 bool skip = false;
6460 if (firstBinding >= device_limits.maxVertexInputBindings) {
6461 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6462 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6463 firstBinding, device_limits.maxVertexInputBindings);
6464 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6465 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6466 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6467 "maxVertexInputBindings (%u)",
6468 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6469 }
6470
6471 for (uint32_t i = 0; i < bindingCount; ++i) {
6472 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006473 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006474 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6475 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6476 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6477 } else {
6478 if (pOffsets[i] != 0) {
6479 skip |=
6480 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6481 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6482 }
6483 }
6484 }
6485 if (pStrides) {
6486 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6487 skip |=
6488 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006489 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i,
Piers Daniell39842ee2020-07-10 16:42:33 -06006490 pStrides[i], device_limits.maxVertexInputBindingStride);
6491 }
6492 }
6493 }
6494
6495 return skip;
6496}
sourav parmarcd5fb182020-07-17 12:58:44 -07006497
6498bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6499 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6500 bool skip = false;
6501 for (uint32_t i = 0; i < infoCount; ++i) {
6502 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6503 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6504 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6505 }
6506 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6507 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6508 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6509 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6510 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6511 api_name);
6512 }
6513 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6514 skip |=
6515 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6516 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6517 }
6518 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6519 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6520 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6521 }
6522 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6523 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6524 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6525 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6526 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6527 api_name);
6528 }
6529 if (pInfos[i].pGeometries) {
6530 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6531 skip |= validate_ranged_enum(
6532 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6533 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6534 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6535 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006536 skip |= validate_struct_type(
6537 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6538 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6539 &(pInfos[i].pGeometries[j].geometry.triangles),
6540 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6541 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6542 skip |= validate_struct_pnext(
6543 api_name,
6544 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6545 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6546 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6547 skip |=
6548 validate_ranged_enum(api_name,
6549 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6550 ParameterName::IndexVector{i, j}),
6551 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6552 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6553 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6554 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6555 &pInfos[i].pGeometries[j].geometry.triangles,
6556 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6557 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6558 skip |= validate_ranged_enum(
6559 api_name,
6560 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6561 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6562 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6563
6564 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6565 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6566 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6567 }
6568 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6569 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6570 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6571 skip |=
6572 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6573 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6574 api_name);
6575 }
6576 }
6577 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6578 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6579 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6580 &pInfos[i].pGeometries[j].geometry.instances,
6581 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6582 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6583 skip |= validate_struct_type(
6584 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6585 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6586 &(pInfos[i].pGeometries[j].geometry.instances),
6587 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6588 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6589 skip |= validate_struct_pnext(
6590 api_name,
6591 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6592 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6593 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6594
6595 skip |= validate_bool32(api_name,
6596 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6597 ParameterName::IndexVector{i, j}),
6598 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6599 }
6600 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6601 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6602 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6603 &pInfos[i].pGeometries[j].geometry.aabbs,
6604 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6605 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6606 skip |= validate_struct_type(
6607 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6608 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6609 &(pInfos[i].pGeometries[j].geometry.aabbs),
6610 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6611 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6612 skip |= validate_struct_pnext(
6613 api_name,
6614 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6615 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6616 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6617 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6618 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6619 "(%s):stride must be less than or equal to 2^32-1", api_name);
6620 }
6621 }
6622 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6623 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6624 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6625 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6626 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6627 api_name);
6628 }
6629 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6630 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6631 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6632 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6633 "of elements of"
6634 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6635 api_name);
6636 }
6637 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6638 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6639 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6640 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6641 api_name);
6642 }
6643 }
6644 }
6645 }
6646 if (pInfos[i].ppGeometries != NULL) {
6647 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6648 skip |= validate_ranged_enum(
6649 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6650 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6651 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6652 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006653 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6654 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6655 &pInfos[i].ppGeometries[j]->geometry.triangles,
6656 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6657 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6658 skip |= validate_struct_type(
6659 api_name,
6660 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6661 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6662 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6663 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6664 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6665 skip |= validate_struct_pnext(
6666 api_name,
6667 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6668 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6669 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6670 skip |= validate_ranged_enum(api_name,
6671 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6672 ParameterName::IndexVector{i, j}),
6673 "VkFormat", AllVkFormatEnums,
6674 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6675 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6676 skip |= validate_ranged_enum(api_name,
6677 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6678 ParameterName::IndexVector{i, j}),
6679 "VkIndexType", AllVkIndexTypeEnums,
6680 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6681 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6682 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6683 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6684 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6685 }
6686 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6687 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6688 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6689 skip |=
6690 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6691 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6692 api_name);
6693 }
6694 }
6695 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6696 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6697 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6698 &pInfos[i].ppGeometries[j]->geometry.instances,
6699 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6700 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6701 skip |= validate_struct_type(
6702 api_name,
6703 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6704 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6705 &(pInfos[i].ppGeometries[j]->geometry.instances),
6706 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6707 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6708 skip |= validate_struct_pnext(
6709 api_name,
6710 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6711 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6712 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6713 skip |= validate_bool32(api_name,
6714 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6715 ParameterName::IndexVector{i, j}),
6716 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6717 }
6718 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6719 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6720 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6721 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6722 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6723 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6724 skip |= validate_struct_type(
6725 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6726 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6727 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6728 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6729 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6730 skip |= validate_struct_pnext(
6731 api_name,
6732 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6733 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6734 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6735 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6736 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6737 "(%s):stride must be less than or equal to 2^32-1", api_name);
6738 }
6739 }
6740 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6741 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6742 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6743 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6744 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6745 api_name);
6746 }
6747 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6748 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6749 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6750 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6751 "of elements of"
6752 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6753 api_name);
6754 }
6755 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6756 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6757 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6758 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6759 api_name);
6760 }
6761 }
6762 }
6763 }
6764 }
6765 return skip;
6766}
6767bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6768 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6769 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6770 bool skip = false;
6771 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6772 for (uint32_t i = 0; i < infoCount; ++i) {
6773 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6774 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6775 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6776 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6777 "scratchData.deviceAddress member must be a multiple of "
6778 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6779 }
6780 for (uint32_t k = 0; k < infoCount; ++k) {
6781 if (i == k) continue;
6782 bool found = false;
6783 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6784 skip |= LogError(
6785 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6786 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6787 "not be "
6788 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6789 i, k);
6790 found = true;
6791 }
6792 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6793 skip |= LogError(
6794 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6795 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6796 "not be "
6797 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6798 i, k);
6799 found = true;
6800 }
6801 if (found) break;
6802 }
6803 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6804 if (pInfos[i].pGeometries) {
6805 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6806 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6807 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6808 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6809 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6810 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6811 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6812 }
6813 } else {
6814 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6815 skip |=
6816 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6817 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6818 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6819 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6820 }
6821 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006822 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006823 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6824 skip |= LogError(
6825 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6826 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6827 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6828 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006829 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6830 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006831 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6832 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6833 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6834 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6835 }
6836 }
6837 } else if (pInfos[i].ppGeometries) {
6838 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6839 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6840 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6841 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6842 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6843 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6844 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6845 }
6846 } else {
6847 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6848 skip |=
6849 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6850 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6851 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6852 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6853 }
6854 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006855 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006856 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6857 skip |= LogError(
6858 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6859 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6860 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6861 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006862 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6863 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006864 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6865 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6866 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6867 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6868 }
6869 }
6870 }
6871 }
6872 }
6873 return skip;
6874}
6875
6876bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6877 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6878 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6879 const uint32_t *const *ppMaxPrimitiveCounts) const {
6880 bool skip = false;
6881 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6882 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006883 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006884 if (!ray_tracing_acceleration_structure_features ||
6885 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6886 skip |= LogError(
6887 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6888 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6889 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6890 }
6891 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006892 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6893 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6894 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6895 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6896 "scratchData.deviceAddress member must be a multiple of "
6897 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6898 }
6899 for (uint32_t k = 0; k < infoCount; ++k) {
6900 if (i == k) continue;
6901 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6902 skip |=
6903 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6904 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6905 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6906 "any other element [%d) of pInfos.",
6907 i, k);
6908 break;
6909 }
6910 }
6911 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6912 if (pInfos[i].pGeometries) {
6913 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6914 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6915 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6916 skip |= LogError(
6917 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6918 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6919 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6920 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6921 }
6922 } else {
6923 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6924 skip |= LogError(
6925 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6926 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6927 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6928 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6929 }
6930 }
6931 }
6932 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6933 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6934 skip |= LogError(
6935 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6936 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6937 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6938 }
6939 }
6940 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6941 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6942 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6943 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6944 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6945 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6946 }
6947 }
6948 } else if (pInfos[i].ppGeometries) {
6949 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6950 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6951 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6952 skip |= LogError(
6953 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6954 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6955 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6956 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6957 }
6958 } else {
6959 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6960 skip |= LogError(
6961 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6962 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6963 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6964 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6965 }
6966 }
6967 }
6968 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6969 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6970 skip |= LogError(
6971 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6972 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6973 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6974 }
6975 }
6976 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6977 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6978 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6979 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6980 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6981 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6982 }
6983 }
6984 }
6985 }
6986 }
6987 return skip;
6988}
6989
6990bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6991 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6992 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6993 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6994 bool skip = false;
6995 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6996 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006997 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006998 if (!ray_tracing_acceleration_structure_features ||
6999 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7000 skip |=
7001 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7002 "vkBuildAccelerationStructuresKHR: The "
7003 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7004 }
7005 for (uint32_t i = 0; i < infoCount; ++i) {
7006 for (uint32_t j = 0; j < infoCount; ++j) {
7007 if (i == j) continue;
7008 bool found = false;
7009 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7010 skip |= LogError(
7011 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7012 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
7013 "not be "
7014 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7015 i, j);
7016 found = true;
7017 }
7018 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7019 skip |= LogError(
7020 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7021 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
7022 "not be "
7023 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7024 i, j);
7025 found = true;
7026 }
7027 if (found) break;
7028 }
7029 }
7030 return skip;
7031}
7032
7033bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7034 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7035 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7036 bool skip = false;
7037 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7038 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007039 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7040 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007041 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7042 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7043 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7044 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7045 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7046 }
7047 return skip;
7048}
sfricke-samsungecafb192021-01-17 08:21:14 -08007049
7050bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7051 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7052 const VkAllocationCallbacks *pAllocator,
7053 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7054 bool skip = false;
7055 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7056 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7057 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7058 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7059 }
7060 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007061}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007062
7063bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7064 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7065 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7066 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7067 bool skip = false;
7068 const auto *vertex_input_dynamic_state_features =
7069 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7070 const auto *vertex_attribute_divisor_features =
7071 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7072
7073 // VUID-vkCmdSetVertexInputEXT-None-04790
7074 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7075 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7076 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7077 }
7078
7079 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7080 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7081 skip |=
7082 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7083 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7084 }
7085
7086 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7087 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7088 skip |= LogError(
7089 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7090 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7091 }
7092
7093 // VUID-vkCmdSetVertexInputEXT-binding-04793
7094 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7095 bool binding_found = false;
7096 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7097 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7098 binding_found = true;
7099 break;
7100 }
7101 }
7102 if (!binding_found) {
7103 skip |=
7104 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7105 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
7106 }
7107 }
7108
7109 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7110 if (vertexBindingDescriptionCount > 1) {
7111 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7112 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7113 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7114 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7115 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
7116 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
7117 }
7118 }
7119 }
7120 }
7121
7122 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7123 if (vertexAttributeDescriptionCount > 1) {
7124 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7125 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7126 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7127 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7128 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
7129 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
7130 }
7131 }
7132 }
7133 }
7134
7135 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7136 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7137 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
7138 skip |= LogError(
7139 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7140 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
7141 }
7142
7143 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7144 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
7145 skip |= LogError(
7146 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7147 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
7148 binding);
7149 }
7150
7151 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7152 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7153 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7154 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7155 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7156 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7157 binding);
7158 }
7159
7160 if (pVertexBindingDescriptions[binding].divisor > 1) {
7161 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7162 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7163 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7164 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7165 "vertexAttributeInstanceRateDivisor is not enabled",
7166 binding);
7167 } else {
7168 // VUID-VkVertexInputBindingDescription2EXT-divisor-04800
7169 if (pVertexBindingDescriptions[binding].divisor >
7170 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7171 skip |= LogError(
7172 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04800",
7173 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7174 binding);
7175 }
7176
7177 // VUID-VkVertexInputBindingDescription2EXT-divisor-04801
7178 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7179 skip |=
7180 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04801",
7181 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7182 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7183 binding);
7184 }
7185 }
7186 }
7187 }
7188
7189 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7190 // VUID-VkVertexInputAttributeDescription2EXT-location-04802
7191 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7192 skip |= LogError(
7193 device, "VUID-VkVertexInputAttributeDescription2EXT-location-04802",
7194 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7195 attribute);
7196 }
7197
7198 // VUID-VkVertexInputAttributeDescription2EXT-binding-04803
7199 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7200 skip |= LogError(
7201 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-04803",
7202 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7203 attribute);
7204 }
7205
7206 // VUID-VkVertexInputAttributeDescription2EXT-offset-04804
7207 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7208 skip |= LogError(
7209 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-04804",
7210 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7211 attribute);
7212 }
7213
7214 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7215 VkFormatProperties properties;
7216 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7217 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7218 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7219 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7220 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7221 attribute);
7222 }
7223 }
7224
7225 return skip;
7226}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007227
7228bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7229 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7230 const void *pValues) const {
7231 bool skip = false;
7232 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7233 // Check that offset + size don't exceed the max.
7234 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7235 if (offset >= max_push_constants_size) {
7236 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7237 "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset,
7238 max_push_constants_size);
7239 }
7240 if (size > max_push_constants_size - offset) {
7241 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
7242 "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.",
7243 offset, size, max_push_constants_size);
7244 }
7245
7246 // size needs to be non-zero and a multiple of 4.
7247 if (size & 0x3) {
7248 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.",
7249 size);
7250 }
7251
7252 // offset needs to be a multiple of 4.
7253 if ((offset & 0x3) != 0) {
7254 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007255 "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007256 }
7257 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007258}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007259
7260bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7261 uint32_t srcCacheCount,
7262 const VkPipelineCache *pSrcCaches) const {
7263 bool skip = false;
7264 if (pSrcCaches) {
7265 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7266 if (pSrcCaches[index0] == dstCache) {
7267 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7268 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7269 report_data->FormatHandle(dstCache).c_str());
7270 break;
7271 }
7272 }
7273 }
7274 return skip;
7275}