blob: be0b72ca9e49d7b7ae21fa6fdc06fba8f3d6ba8c [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 {
375 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
376 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
377 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700378 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
379 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
380 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600381 }
382 }
383
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600384 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
385 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700386 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600387 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800388 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700389 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800390 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700391 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600392 }
393 }
394
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700395 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500396 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700397 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500398 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
399 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
400 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
401 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700402 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700403 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
404 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
405 skip |= LogError(
406 device,
407 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
408 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
409 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700410 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700411 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600412 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
413 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
414 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
415 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600416 }
417
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700418 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700419 if (vulkan_11_features) {
420 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
421 while (current) {
422 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
423 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
424 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
425 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
426 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
427 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700428 skip |= LogError(
429 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700430 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
431 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
432 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
433 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
434 break;
435 }
436 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
437 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800438
439 // Check features are enabled if matching extension is passed in as well
440 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
441 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
442 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
443 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
444 skip |= LogError(
445 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
446 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
447 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
448 }
449 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700450 }
451
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700452 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700453 if (vulkan_12_features) {
454 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
455 while (current) {
456 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
457 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
458 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
459 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
460 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
461 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
462 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
463 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
464 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
465 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
466 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
467 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700469 skip |= LogError(
470 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700471 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
472 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
473 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
474 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
475 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
476 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
477 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
478 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
479 break;
480 }
481 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
482 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700483 // Check features are enabled if matching extension is passed in as well
484 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
485 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
486 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
487 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
488 skip |= LogError(
489 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
490 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
491 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
492 }
493 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
494 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
495 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
496 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
497 "is not VK_TRUE.",
498 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
499 }
500 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
501 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
502 skip |= LogError(
503 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
504 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
505 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
506 }
507 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
508 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
509 skip |= LogError(
510 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
511 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
512 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
513 }
514 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
515 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
516 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
517 skip |=
518 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
519 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
520 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
521 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
522 }
523 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700524 }
525
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600526 // Validate pCreateInfo->pQueueCreateInfos
527 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600528
529 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700530 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
531 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700533 skip |=
534 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
535 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
536 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
537 "index value.",
538 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600539 }
540
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700541 if (queue_create_info.pQueuePriorities != nullptr) {
542 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
543 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600544 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
546 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
547 "] (=%f) is not between 0 and 1 (inclusive).",
548 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550 }
551 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700552
553 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700554 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700555 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700556 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700557 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700558 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700559 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700560 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700561 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700562 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700563 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
564 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
565 "protectedMemory feature being set as well.");
566 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600567 }
568 }
569
sfricke-samsung30a57412020-05-15 21:14:54 -0700570 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700571 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700572 VkBool32 variable_pointers = VK_FALSE;
573 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700574 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700575 variable_pointers = vulkan_11_features->variablePointers;
576 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700577 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700578 variable_pointers = variable_pointers_features->variablePointers;
579 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700580 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700581 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700582 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
583 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
584 }
585
sfricke-samsungfd76c342020-05-29 23:13:43 -0700586 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700587 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700588 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700589 VkBool32 multiview_geometry_shader = VK_FALSE;
590 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700591 if (vulkan_11_features) {
592 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700593 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
594 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700595 } else if (multiview_features) {
596 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700597 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
598 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700599 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700600 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700601 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
602 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
603 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700604 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700605 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
606 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
607 }
608
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600609 return skip;
610}
611
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500612bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700613 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700614 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
615 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
616 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600617 }
618
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700619 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600620}
621
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700622bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500623 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100624 bool skip = false;
625
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700627 skip |=
628 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600629
630 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
631 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
632 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
633 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700634 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
635 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
636 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600637 }
638
639 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
640 // queueFamilyIndexCount uint32_t values
641 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700642 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
643 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
644 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
645 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600646 }
647 }
648
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700649 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
650 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
651 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
652 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
653 }
654
655 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
656 skip |=
657 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
658 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
659 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
660 }
661
662 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
663 skip |=
664 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
665 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
666 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
667 }
668
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600669 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
670 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
671 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
672 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700673 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
674 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
675 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600676 }
677 }
678
679 return skip;
680}
681
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700682bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500683 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600684 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600685
686 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800687 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700688 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600689 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
690 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
691 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
692 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700693 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
694 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
695 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600696 }
697
698 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
699 // queueFamilyIndexCount uint32_t values
700 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
702 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
703 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
704 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600705 }
706 }
707
Dave Houlton413a6782018-05-22 13:01:54 -0600708 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600710 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600712 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700713 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714
Dave Houlton413a6782018-05-22 13:01:54 -0600715 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700716 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600717 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600719
Dave Houlton130c0212018-01-29 13:39:56 -0700720 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700721 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
722 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700723 skip |= LogError(
724 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600725 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
726 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700727 }
728
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600729 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100730 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
731 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700732 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
733 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
734 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600735 }
736
737 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700738 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100739 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
741 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
742 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
743 ") are not equal.",
744 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100745 }
746
747 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700748 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
749 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
750 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
751 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100752 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 }
754
755 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700756 skip |= LogError(
757 device, "VUID-VkImageCreateInfo-imageType-00957",
758 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600759 }
760 }
761
Dave Houlton130c0212018-01-29 13:39:56 -0700762 // 3D image may have only 1 layer
763 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700764 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
765 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700766 }
767
Dave Houlton130c0212018-01-29 13:39:56 -0700768 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
769 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
770 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
771 // At least one of the legal attachment bits must be set
772 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
774 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700775 }
776 // No flags other than the legal attachment bits may be set
777 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
778 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700779 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
780 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700781 }
782 }
783
Jeff Bolzef40fec2018-09-01 22:04:34 -0500784 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700785 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500786 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700787 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700788 ? static_cast<uint32_t>(ceil(log2(max_dim)))
789 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
790 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600791 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700792 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
793 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
794 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600795 }
796
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700797 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700798 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
799 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
800 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600801 }
802
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700803 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700804 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
805 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
806 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100807 }
808
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700809 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700810 skip |= LogError(
811 device, "VUID-VkImageCreateInfo-flags-01924",
812 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
813 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
814 }
815
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600816 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
817 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700818 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
819 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700820 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
821 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
822 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600823 }
824
825 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700826 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600827 // Linear tiling is unsupported
828 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700829 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700830 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
831 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600832 }
833
834 // Sparse 1D image isn't valid
835 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700836 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
837 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600838 }
839
840 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700841 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700842 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
843 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
844 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600845 }
846
847 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700848 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700849 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
850 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
851 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600852 }
853
854 // Multi-sample 2D image when device doesn't support it
855 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700856 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600857 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700858 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
859 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
860 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700861 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600862 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700863 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
864 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
865 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700866 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600867 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
869 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
870 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700871 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600872 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700873 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
874 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
875 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600876 }
877 }
878 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500879
Jeff Bolz9af91c52018-09-01 21:53:57 -0500880 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
881 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700882 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
883 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
884 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500885 }
886 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700887 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
888 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
889 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500890 }
891 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700892 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
893 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
894 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500895 }
896 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500897
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700898 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600899 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700900 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
901 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
902 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500903 }
904
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700905 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700906 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
907 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800908 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
909 "depth/stencil format.",
910 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500911 }
912
Dave Houlton142c4cb2018-10-17 15:04:41 -0600913 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700914 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
915 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
916 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
917 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500918 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600919 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700920 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
921 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
922 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
923 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500924 }
925 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500926
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700927 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800928 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700929 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
930 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800931 "format (%s) must be a depth or depth/stencil format.",
932 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700933 }
934
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700935 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500936 if (image_stencil_struct != nullptr) {
937 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
938 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
939 // No flags other than the legal attachment bits may be set
940 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
941 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700942 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
943 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
944 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
945 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500946 }
947 }
948
sfricke-samsung61a57c02021-01-10 21:35:12 -0800949 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500950 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
951 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800952 skip |= LogError(
953 device, "VUID-VkImageCreateInfo-Format-02536",
954 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
955 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
956 "maxFramebufferWidth (%u)",
957 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500958 }
959
960 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800961 skip |= LogError(
962 device, "VUID-VkImageCreateInfo-format-02537",
963 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
964 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
965 "maxFramebufferHeight (%u)",
966 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500967 }
968 }
969
970 if (!physical_device_features.shaderStorageImageMultisample &&
971 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
972 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
973 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700974 LogError(device, "VUID-VkImageCreateInfo-format-02538",
975 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
976 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
977 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500978 }
979
980 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
981 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700982 skip |= LogError(
983 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500984 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
985 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
986 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
987 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
988 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700989 skip |= LogError(
990 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500991 "vkCreateImage(): Depth-stencil image in which usage does not include "
992 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
993 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
994 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
995 }
996
997 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
998 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700999 skip |= LogError(
1000 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001001 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1002 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1003 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1004 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1005 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001006 skip |= LogError(
1007 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001008 "vkCreateImage(): Depth-stencil image in which usage does not include "
1009 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1010 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1011 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1012 }
1013 }
1014 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001015
1016 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1017 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1018 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1019 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1020 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1021 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001022
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001023 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001024 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001025 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1026 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001027 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1028 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1029 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1030 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1031 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1032 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1033 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001034 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001035 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1036 } else if (drm_format_mod_list != nullptr) {
1037 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1038 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1039 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001040 }
1041 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1042 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1043 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1044 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1045 "in the pNext chain");
1046 }
1047 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001048
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001049 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001050 bool image_create_maybe_linear = false;
1051 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1052 image_create_maybe_linear = true;
1053 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1054 image_create_maybe_linear = false;
1055 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1056 image_create_maybe_linear =
1057 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001058 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001059 }
1060
1061 // If multi-sample, validate type, usage, tiling and mip levels.
1062 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001063 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001064 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1065 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1066 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1067 }
1068
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001069 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001070 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1071 image_create_maybe_linear)) {
1072 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1073 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1074 }
1075
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001076 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1077 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1078 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1079 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1080 "imageType must be VK_IMAGE_TYPE_2D.");
1081 }
1082 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1083 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1084 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1085 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1086 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001087 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001088 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001089 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1090 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1091 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1092 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1093 }
1094 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1095 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1096 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1097 "imageType must be VK_IMAGE_TYPE_2D.");
1098 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001099 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001100 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1101 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1102 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1103 }
1104 if (pCreateInfo->mipLevels != 1) {
1105 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1106 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1107 pCreateInfo->mipLevels);
1108 }
1109 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001110
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001111 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001112 if (swapchain_create_info != nullptr) {
1113 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1114 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1115 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1116 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1117 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1118 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1119
1120 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1121 // also implicitly forces the check above that extent.depth is 1
1122 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1123 string_VkImageType(pCreateInfo->imageType));
1124 }
1125 if (pCreateInfo->mipLevels != 1) {
1126 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1127 pCreateInfo->mipLevels);
1128 }
1129 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1130 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1131 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1132 }
1133 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1134 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1135 base_message, string_VkImageTiling(pCreateInfo->tiling));
1136 }
1137 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1138 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1139 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1140 }
1141 const VkImageCreateFlags valid_flags =
1142 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001143 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001144 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001145 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001146 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001147 }
1148 }
1149 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001150
1151 // If Chroma subsampled format ( _420_ or _422_ )
1152 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1153 skip |=
1154 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1155 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1156 ") must be a multiple of 2.",
1157 string_VkFormat(image_format), pCreateInfo->extent.width);
1158 }
1159 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1160 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1161 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1162 ") must be a multiple of 2.",
1163 string_VkFormat(image_format), pCreateInfo->extent.height);
1164 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001165
1166 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1167 if (format_list_info) {
1168 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1169 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1170 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1171 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1172 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1173 viewFormatCount);
1174 }
1175 // Check if viewFormatCount is not zero that it is all compatible
1176 for (uint32_t i = 0; i < viewFormatCount; i++) {
1177 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1178 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1179 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1180 "VkImageCreateInfo::format (%s) are not compatible.",
1181 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1182 }
1183 }
1184 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001185 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001186
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001187 return skip;
1188}
1189
Jeff Bolz99e3f632020-03-24 22:59:22 -05001190bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1191 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1192 bool skip = false;
1193
1194 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001195 // Validate feature set if using CUBE_ARRAY
1196 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1197 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1198 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1199 "enabling the imageCubeArray feature.");
1200 }
1201
Jeff Bolz99e3f632020-03-24 22:59:22 -05001202 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1203 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1204 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001205 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001206 pCreateInfo->subresourceRange.layerCount);
1207 }
1208 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001209 skip |= LogError(
1210 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1211 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1212 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001213 }
1214 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001215
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001216 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001217 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1218 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1219 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1220 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1221 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1222 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1223 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1224 }
1225 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1226 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1227 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1228 "not an ASTC format.",
1229 string_VkFormat(pCreateInfo->format));
1230 }
1231 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001232
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001233 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001234 if (ycbcr_conversion != nullptr) {
1235 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1236 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1237 skip |= LogError(
1238 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1239 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1240 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1241 "r swizzle = %s\n"
1242 "g swizzle = %s\n"
1243 "b swizzle = %s\n"
1244 "a swizzle = %s\n",
1245 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1246 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1247 }
1248 }
1249 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001250 }
1251 return skip;
1252}
1253
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001254bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001255 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001256 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001257
1258 // Note: for numerical correctness
1259 // - float comparisons should expect NaN (comparison always false).
1260 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1261
1262 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001263 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001264 if (v1_f <= 0.0f) return true;
1265
1266 float intpart;
1267 const float fract = modff(v1_f, &intpart);
1268
1269 assert(std::numeric_limits<float>::radix == 2);
1270 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1271 if (intpart >= u32_max_plus1) return false;
1272
1273 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001274 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001275 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001276 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001277 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001278 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001279 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001280 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001281 };
1282
1283 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1284 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1285 return (v1_f <= v2_f);
1286 };
1287
1288 // width
1289 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001290 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001291
1292 if (!(viewport.width > 0.0f)) {
1293 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001294 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1295 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001296 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1297 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001298 skip |= LogError(object, "VUID-VkViewport-width-01771",
1299 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1300 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001301 }
1302
1303 // height
1304 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001305 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001306 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001307
1308 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1309 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001310 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1311 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001312 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1313 height_healthy = false;
1314
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001315 skip |= LogError(object, "VUID-VkViewport-height-01773",
1316 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1317 ").",
1318 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001319 }
1320
1321 // x
1322 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001323 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001324 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001325 skip |= LogError(object, "VUID-VkViewport-x-01774",
1326 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1327 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001328 }
1329
1330 // x + width
1331 if (x_healthy && width_healthy) {
1332 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001333 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001334 skip |= LogError(
1335 object, "VUID-VkViewport-x-01232",
1336 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1337 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1338 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001339 }
1340 }
1341
1342 // y
1343 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001344 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001345 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001346 skip |= LogError(object, "VUID-VkViewport-y-01775",
1347 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1348 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001349 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001350 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001351 skip |= LogError(object, "VUID-VkViewport-y-01776",
1352 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1353 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001354 }
1355
1356 // y + height
1357 if (y_healthy && height_healthy) {
1358 const float boundary = viewport.y + viewport.height;
1359
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001360 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001361 skip |= LogError(object, "VUID-VkViewport-y-01233",
1362 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1363 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1364 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001365 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001366 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001367 LogError(object, "VUID-VkViewport-y-01777",
1368 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1369 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1370 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001371 }
1372 }
1373
sfricke-samsungfd06d422021-01-22 02:17:21 -08001374 // 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 -07001375 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001376 // minDepth
1377 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001378 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001379 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001380 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1381 "[0.0, 1.0] range.",
1382 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001383 }
1384
1385 // maxDepth
1386 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001387 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001388 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001389 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1390 "[0.0, 1.0] range.",
1391 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001392 }
1393 }
1394
1395 return skip;
1396}
1397
Dave Houlton142c4cb2018-10-17 15:04:41 -06001398struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001399 VkShadingRatePaletteEntryNV shadingRate;
1400 uint32_t width;
1401 uint32_t height;
1402};
1403
1404// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001405static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001406 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1407 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1408 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1409 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1410 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1411 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001412};
1413
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001414bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001415 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001416
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001417 SampleOrderInfo *sample_order_info;
1418 uint32_t info_idx = 0;
1419 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1420 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1421 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001422 break;
1423 }
1424 }
1425
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001426 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001427 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1428 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1429 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001430 return skip;
1431 }
1432
Dave Houlton142c4cb2018-10-17 15:04:41 -06001433 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001434 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001435 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1436 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1437 ") must "
1438 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1439 "is set in framebufferNoAttachmentsSampleCounts.",
1440 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001441 }
1442
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001443 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001444 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1445 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1446 ") must "
1447 "be equal to the product of sampleCount (=%" PRIu32
1448 "), the fragment width for shadingRate "
1449 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001450 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001451 }
1452
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001453 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001454 skip |= LogError(
1455 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001456 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1457 ") must "
1458 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001459 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001460 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001461
1462 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001463 // the first width*height*sampleCount bits to all be set. Note: There is no
1464 // guarantee that 64 bits is enough, but practically it's unlikely for an
1465 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001466 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001467 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001468 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001469 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1470 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001471 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1472 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001473 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001474 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001475 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1476 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001477 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001478 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001479 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1480 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001481 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001482 uint32_t idx =
1483 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1484 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001485 }
1486
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001487 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1488 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001489 skip |= LogError(
1490 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001491 "The array pSampleLocations must contain exactly one entry for "
1492 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001493 }
1494
1495 return skip;
1496}
1497
sfricke-samsung51303fb2021-05-09 19:09:13 -07001498bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1499 const VkAllocationCallbacks *pAllocator,
1500 VkPipelineLayout *pPipelineLayout) const {
1501 bool skip = false;
1502 // Validate layout count against device physical limit
1503 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1504 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
1505 "vkCreatePipelineLayout(): setLayoutCount (%d) exceeds physical device maxBoundDescriptorSets limit (%d).",
1506 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1507 }
1508
1509 // Validate Push Constant ranges
1510 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1511 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1512 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1513 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1514 // Check that offset + size don't exceed the max.
1515 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1516 if (offset >= max_push_constants_size) {
1517 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
1518 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) that exceeds this "
1519 "device's maxPushConstantSize of %u.",
1520 i, offset, max_push_constants_size);
1521 }
1522 if (size > max_push_constants_size - offset) {
1523 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
1524 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u] offset (%u) and size (%u) "
1525 "together exceeds this device's maxPushConstantSize of %u.",
1526 i, offset, size, max_push_constants_size);
1527 }
1528
1529 // size needs to be non-zero and a multiple of 4.
1530 if (size == 0) {
1531 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
1532 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not greater than zero.",
1533 i, size);
1534 }
1535 if (size & 0x3) {
1536 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
1537 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not a multiple of 4.", i,
1538 size);
1539 }
1540
1541 // offset needs to be a multiple of 4.
1542 if ((offset & 0x3) != 0) {
1543 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
1544 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) is not a multiple of 4.",
1545 i, offset);
1546 }
1547 }
1548
1549 // 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.
1550 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1551 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1552 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
1553 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1554 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %d and %d.", i, j);
1555 }
1556 }
1557 }
1558 return skip;
1559}
1560
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001561bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1562 uint32_t createInfoCount,
1563 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1564 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001565 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001566 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001567
1568 if (pCreateInfos != nullptr) {
1569 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001570 bool has_dynamic_viewport = false;
1571 bool has_dynamic_scissor = false;
1572 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001573 bool has_dynamic_depth_bias = false;
1574 bool has_dynamic_blend_constant = false;
1575 bool has_dynamic_depth_bounds = false;
1576 bool has_dynamic_stencil_compare = false;
1577 bool has_dynamic_stencil_write = false;
1578 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001579 bool has_dynamic_viewport_w_scaling_nv = false;
1580 bool has_dynamic_discard_rectangle_ext = false;
1581 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001582 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001583 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001584 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001585 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001586 bool has_dynamic_cull_mode = false;
1587 bool has_dynamic_front_face = false;
1588 bool has_dynamic_primitive_topology = false;
1589 bool has_dynamic_viewport_with_count = false;
1590 bool has_dynamic_scissor_with_count = false;
1591 bool has_dynamic_vertex_input_binding_stride = false;
1592 bool has_dynamic_depth_test_enable = false;
1593 bool has_dynamic_depth_write_enable = false;
1594 bool has_dynamic_depth_compare_op = false;
1595 bool has_dynamic_depth_bounds_test_enable = false;
1596 bool has_dynamic_stencil_test_enable = false;
1597 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001598 bool has_patch_control_points = false;
1599 bool has_rasterizer_discard_enable = false;
1600 bool has_depth_bias_enable = false;
1601 bool has_logic_op = false;
1602 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001603 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001604 if (pCreateInfos[i].pDynamicState != nullptr) {
1605 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1606 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1607 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001608 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1609 if (has_dynamic_viewport == true) {
1610 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1611 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1612 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1613 i);
1614 }
1615 has_dynamic_viewport = true;
1616 }
1617 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1618 if (has_dynamic_scissor == true) {
1619 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1620 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1621 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1622 i);
1623 }
1624 has_dynamic_scissor = true;
1625 }
1626 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1627 if (has_dynamic_line_width == true) {
1628 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1629 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1630 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1631 i);
1632 }
1633 has_dynamic_line_width = true;
1634 }
1635 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1636 if (has_dynamic_depth_bias == true) {
1637 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1638 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1639 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1640 i);
1641 }
1642 has_dynamic_depth_bias = true;
1643 }
1644 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1645 if (has_dynamic_blend_constant == true) {
1646 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1647 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1648 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1649 i);
1650 }
1651 has_dynamic_blend_constant = true;
1652 }
1653 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1654 if (has_dynamic_depth_bounds == true) {
1655 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1656 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1657 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1658 i);
1659 }
1660 has_dynamic_depth_bounds = true;
1661 }
1662 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1663 if (has_dynamic_stencil_compare == true) {
1664 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1665 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1666 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1667 i);
1668 }
1669 has_dynamic_stencil_compare = true;
1670 }
1671 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1672 if (has_dynamic_stencil_write == true) {
1673 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1674 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1675 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1676 i);
1677 }
1678 has_dynamic_stencil_write = true;
1679 }
1680 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1681 if (has_dynamic_stencil_reference == true) {
1682 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1683 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1684 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1685 i);
1686 }
1687 has_dynamic_stencil_reference = true;
1688 }
1689 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1690 if (has_dynamic_viewport_w_scaling_nv == true) {
1691 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1692 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1693 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1694 i);
1695 }
1696 has_dynamic_viewport_w_scaling_nv = true;
1697 }
1698 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1699 if (has_dynamic_discard_rectangle_ext == true) {
1700 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1701 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1702 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1703 i);
1704 }
1705 has_dynamic_discard_rectangle_ext = true;
1706 }
1707 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1708 if (has_dynamic_sample_locations_ext == true) {
1709 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1710 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1711 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1712 i);
1713 }
1714 has_dynamic_sample_locations_ext = true;
1715 }
1716 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1717 if (has_dynamic_exclusive_scissor_nv == true) {
1718 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1719 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1720 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1721 i);
1722 }
1723 has_dynamic_exclusive_scissor_nv = true;
1724 }
1725 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1726 if (has_dynamic_shading_rate_palette_nv == true) {
1727 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1728 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1729 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1730 i);
1731 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001732 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001733 }
1734 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1735 if (has_dynamic_viewport_course_sample_order_nv == true) {
1736 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1737 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1738 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1739 i);
1740 }
1741 has_dynamic_viewport_course_sample_order_nv = true;
1742 }
1743 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1744 if (has_dynamic_line_stipple == true) {
1745 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1746 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1747 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1748 i);
1749 }
1750 has_dynamic_line_stipple = true;
1751 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001752 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1753 if (has_dynamic_cull_mode) {
1754 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1755 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1756 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1757 i);
1758 }
1759 has_dynamic_cull_mode = true;
1760 }
1761 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1762 if (has_dynamic_front_face) {
1763 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1764 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1765 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1766 i);
1767 }
1768 has_dynamic_front_face = true;
1769 }
1770 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1771 if (has_dynamic_primitive_topology) {
1772 skip |= LogError(
1773 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1774 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1775 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1776 i);
1777 }
1778 has_dynamic_primitive_topology = true;
1779 }
1780 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1781 if (has_dynamic_viewport_with_count) {
1782 skip |= LogError(
1783 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1784 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1785 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1786 i);
1787 }
1788 has_dynamic_viewport_with_count = true;
1789 }
1790 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1791 if (has_dynamic_scissor_with_count) {
1792 skip |= LogError(
1793 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1794 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1795 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1796 i);
1797 }
1798 has_dynamic_scissor_with_count = true;
1799 }
1800 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1801 if (has_dynamic_vertex_input_binding_stride) {
1802 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1803 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1804 "listed twice in the "
1805 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1806 i);
1807 }
1808 has_dynamic_vertex_input_binding_stride = true;
1809 }
1810 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1811 if (has_dynamic_depth_test_enable) {
1812 skip |= LogError(
1813 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1814 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1815 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1816 i);
1817 }
1818 has_dynamic_depth_test_enable = true;
1819 }
1820 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1821 if (has_dynamic_depth_write_enable) {
1822 skip |= LogError(
1823 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1824 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1825 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1826 i);
1827 }
1828 has_dynamic_depth_write_enable = true;
1829 }
1830 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1831 if (has_dynamic_depth_compare_op) {
1832 skip |=
1833 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1834 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1835 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1836 i);
1837 }
1838 has_dynamic_depth_compare_op = true;
1839 }
1840 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1841 if (has_dynamic_depth_bounds_test_enable) {
1842 skip |= LogError(
1843 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1844 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1845 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1846 i);
1847 }
1848 has_dynamic_depth_bounds_test_enable = true;
1849 }
1850 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1851 if (has_dynamic_stencil_test_enable) {
1852 skip |= LogError(
1853 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1854 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1855 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1856 i);
1857 }
1858 has_dynamic_stencil_test_enable = true;
1859 }
1860 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1861 if (has_dynamic_stencil_op) {
1862 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1863 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1864 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1865 i);
1866 }
1867 has_dynamic_stencil_op = true;
1868 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001869 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1870 // Not allowed for graphics pipelines
1871 skip |= LogError(
1872 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1873 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1874 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1875 i, state_index);
1876 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001877 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1878 if (has_patch_control_points) {
1879 skip |= LogError(
1880 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1881 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1882 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1883 i);
1884 }
1885 has_patch_control_points = true;
1886 }
1887 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1888 if (has_rasterizer_discard_enable) {
1889 skip |= LogError(
1890 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1891 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1892 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1893 i);
1894 }
1895 has_rasterizer_discard_enable = true;
1896 }
1897 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1898 if (has_depth_bias_enable) {
1899 skip |= LogError(
1900 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1901 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1902 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1903 i);
1904 }
1905 has_depth_bias_enable = true;
1906 }
1907 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1908 if (has_logic_op) {
1909 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1910 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1911 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1912 i);
1913 }
1914 has_logic_op = true;
1915 }
1916 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1917 if (has_primitive_restart_enable) {
1918 skip |= LogError(
1919 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1920 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1921 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1922 i);
1923 }
1924 has_primitive_restart_enable = true;
1925 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001926 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1927 if (has_dynamic_vertex_input) {
1928 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1929 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1930 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1931 i);
1932 }
1933 has_dynamic_vertex_input = true;
1934 }
Petr Kraus299ba622017-11-24 03:09:03 +01001935 }
1936 }
1937
sfricke-samsung3b944422021-01-23 02:15:19 -08001938 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1939 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1940 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1941 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1942 i);
1943 }
1944
1945 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1946 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1947 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1948 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1949 i);
1950 }
1951
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001952 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001953 if ((feedback_struct != nullptr) &&
1954 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001955 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1956 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1957 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1958 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1959 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001960 }
1961
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001962 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001963
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001964 // Collect active stages and other information
1965 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001966 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001967 bool has_eval = false;
1968 bool has_control = false;
1969 if (pCreateInfos[i].pStages != nullptr) {
1970 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1971 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1972
1973 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1974 has_control = true;
1975 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1976 has_eval = true;
1977 }
1978
1979 skip |= validate_string(
1980 "vkCreateGraphicsPipelines",
1981 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1982 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1983 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001984 }
1985
1986 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1987 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1988 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1989 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1990 pCreateInfos[i].pTessellationState,
1991 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1992 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1993
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001994 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001995 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1996
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001997 skip |= validate_struct_pnext(
1998 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1999 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2000 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2001 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2002 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2003 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002004
2005 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2006 pCreateInfos[i].pTessellationState->flags,
2007 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2008 }
2009
2010 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2011 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2012 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2013 pCreateInfos[i].pInputAssemblyState,
2014 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2015 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2016
2017 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2018 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002019 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002020
2021 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2022 pCreateInfos[i].pInputAssemblyState->flags,
2023 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2024
2025 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2026 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2027 pCreateInfos[i].pInputAssemblyState->topology,
2028 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2029
2030 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2031 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2032 }
2033
2034 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002035 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002036
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002037 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002038 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2039 "vkCreateGraphicsPipelines: pararameter "
2040 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
2041 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002042 }
2043
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002044 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002045 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2046 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2047 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2048 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002049 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2050 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002051 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002052 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2053 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002054 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002055 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2056 skip |=
2057 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2058 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2059 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2060 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2061 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2062
2063 skip |= validate_array(
2064 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2065 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2066 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2067 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2068
2069 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002070 for (uint32_t vertex_binding_description_index = 0;
2071 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2072 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002073 skip |= validate_ranged_enum(
2074 "vkCreateGraphicsPipelines",
2075 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2076 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002077 pCreateInfos[i]
2078 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2079 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002080 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2081 }
2082 }
2083
2084 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002085 for (uint32_t vertex_attribute_description_index = 0;
2086 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2087 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002088 skip |= validate_ranged_enum(
2089 "vkCreateGraphicsPipelines",
2090 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2091 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002092 pCreateInfos[i]
2093 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2094 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002095 "VUID-VkVertexInputAttributeDescription-format-parameter");
2096 }
2097 }
2098
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002099 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002100 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2101 "vkCreateGraphicsPipelines: pararameter "
2102 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2103 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2104 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002105 }
2106
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002107 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002108 skip |=
2109 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2110 "vkCreateGraphicsPipelines: pararameter "
2111 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2112 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2113 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002114 }
2115
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002116 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002117 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2118 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002119 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2120 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002121 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2122 "vkCreateGraphicsPipelines: parameter "
2123 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2124 "(%" PRIu32 ") is not distinct.",
2125 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002126 }
2127 vertex_bindings.insert(vertex_bind_desc.binding);
2128
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002129 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002130 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2131 "vkCreateGraphicsPipelines: parameter "
2132 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2133 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2134 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002135 }
2136
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002137 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002138 skip |=
2139 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2140 "vkCreateGraphicsPipelines: parameter "
2141 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2142 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2143 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002144 }
2145 }
2146
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002147 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002148 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2149 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002150 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2151 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002152 skip |= LogError(
2153 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002154 "vkCreateGraphicsPipelines: parameter "
2155 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2156 i, d, vertex_attrib_desc.location);
2157 }
2158 attribute_locations.insert(vertex_attrib_desc.location);
2159
2160 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2161 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002162 skip |= LogError(
2163 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002164 "vkCreateGraphicsPipelines: parameter "
2165 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2166 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2167 i, d, vertex_attrib_desc.binding, i);
2168 }
2169
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002170 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002171 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2172 "vkCreateGraphicsPipelines: parameter "
2173 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2174 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2175 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002176 }
2177
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002178 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002179 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2180 "vkCreateGraphicsPipelines: parameter "
2181 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2182 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2183 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002184 }
2185
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002186 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002187 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2188 "vkCreateGraphicsPipelines: parameter "
2189 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2190 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2191 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002192 }
2193 }
2194 }
2195
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002196 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2197 if (has_control && has_eval) {
2198 if (pCreateInfos[i].pTessellationState == nullptr) {
2199 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2200 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2201 "shader stage and a tessellation evaluation shader stage, "
2202 "pCreateInfos[%d].pTessellationState must not be NULL.",
2203 i, i);
2204 } else {
2205 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2206 skip |= validate_struct_pnext(
2207 "vkCreateGraphicsPipelines",
2208 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2209 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2210 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2211 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002212
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002213 skip |= validate_reserved_flags(
2214 "vkCreateGraphicsPipelines",
2215 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2216 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002217
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002218 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2219 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2220 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2221 "vkCreateGraphicsPipelines: invalid parameter "
2222 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2223 "should be >0 and <=%u.",
2224 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2225 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002226 }
2227 }
2228 }
2229
2230 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2231 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2232 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2233 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002234 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2235 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2236 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2237 "].pViewportState (=NULL) is not a valid pointer.",
2238 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002239 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002240 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2241
2242 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002243 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2244 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2245 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2246 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002247 }
2248
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002249 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002250 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002251 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2252 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002253 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2254 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002255 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002256 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002257 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002258 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002259 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002260 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2261 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002262 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2263 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2264 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002265 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002266
2267 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002268 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002269 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002270 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002271
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002272 auto exclusive_scissor_struct =
2273 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2274 auto shading_rate_image_struct =
2275 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2276 auto coarse_sample_order_struct =
2277 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002278 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002279 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002280 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002281 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002282
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002283 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002284 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002285 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2286 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2287 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2288 ") is not 1.",
2289 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002290 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002291
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002292 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002293 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2294 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2295 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2296 ") is not 1.",
2297 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002299
Dave Houlton142c4cb2018-10-17 15:04:41 -06002300 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2301 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002302 skip |= LogError(
2303 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2304 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2305 "disabled, but pCreateInfos[%" PRIu32
2306 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2307 ") is not 1.",
2308 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002309 }
2310
Jeff Bolz9af91c52018-09-01 21:53:57 -05002311 if (shading_rate_image_struct &&
2312 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002313 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2314 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2315 "disabled, but pCreateInfos[%" PRIu32
2316 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2317 ") is neither 0 nor 1.",
2318 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002319 }
2320
Petr Krausa6103552017-11-16 21:21:58 +01002321 } else { // multiViewport enabled
2322 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002323 if (!has_dynamic_viewport_with_count) {
2324 skip |= LogError(
2325 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2326 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2327 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002328 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002329 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2330 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2331 "].pViewportState->viewportCount (=%" PRIu32
2332 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2333 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002334 } else if (has_dynamic_viewport_with_count) {
2335 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2336 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2337 "].pViewportState->viewportCount (=%" PRIu32
2338 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2339 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002340 }
Petr Krausa6103552017-11-16 21:21:58 +01002341
2342 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002343 if (!has_dynamic_scissor_with_count) {
2344 skip |= LogError(
2345 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2346 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2347 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002348 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002349 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2350 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2351 "].pViewportState->scissorCount (=%" PRIu32
2352 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2353 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002354 } else if (has_dynamic_scissor_with_count) {
2355 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2356 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2357 "].pViewportState->scissorCount (=%" PRIu32
2358 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2359 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002360 }
2361 }
2362
ziga-lunarg845883b2021-07-14 15:05:00 +02002363 if (!has_dynamic_scissor && viewport_state.pScissors) {
2364 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2365 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002366
2367 if (scissor.offset.x < 0) {
2368 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2369 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2370 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2371 scissor.offset.x, i, scissor_i);
2372 }
2373
2374 if (scissor.offset.y < 0) {
2375 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2376 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2377 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2378 scissor.offset.y, i, scissor_i);
2379 }
2380
ziga-lunarg845883b2021-07-14 15:05:00 +02002381 const int64_t x_sum =
2382 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2383 if (x_sum > std::numeric_limits<int32_t>::max()) {
2384 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2385 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2386 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2387 "] will overflow int32_t.",
2388 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2389 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002390
ziga-lunarg845883b2021-07-14 15:05:00 +02002391 const int64_t y_sum =
2392 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2393 if (y_sum > std::numeric_limits<int32_t>::max()) {
2394 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2395 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2396 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2397 "] will overflow int32_t.",
2398 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2399 }
2400 }
2401 }
2402
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002403 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002404 skip |=
2405 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2406 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2407 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2408 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002409 }
2410
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002411 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002412 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2413 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2414 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2415 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2416 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002417 }
2418
Piers Daniell39842ee2020-07-10 16:42:33 -06002419 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2420 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002421 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2422 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2423 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2424 "].pViewportState->viewportCount (=%" PRIu32 ").",
2425 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002426 }
2427
Dave Houlton142c4cb2018-10-17 15:04:41 -06002428 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002429 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002430 skip |=
2431 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2432 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2433 ") must be zero or identical to pCreateInfos[%" PRIu32
2434 "].pViewportState->viewportCount (=%" PRIu32 ").",
2435 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002436 }
2437
Dave Houlton142c4cb2018-10-17 15:04:41 -06002438 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002439 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002440 skip |= LogError(
2441 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002442 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2443 "] "
2444 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2445 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2446 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002447 }
2448
Petr Krausa6103552017-11-16 21:21:58 +01002449 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002450 skip |= LogError(
2451 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002452 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2453 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002454 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2455 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002456 }
2457
2458 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002459 skip |= LogError(
2460 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002461 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2462 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002463 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2464 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002465 }
2466
Jeff Bolz3e71f782018-08-29 23:15:45 -05002467 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002468 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2469 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2470 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002471 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002472 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2473 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2474 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2475 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002476 }
2477
Jeff Bolz9af91c52018-09-01 21:53:57 -05002478 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002479 shading_rate_image_struct->viewportCount > 0 &&
2480 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002481 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002482 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002483 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002484 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2485 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002486 i, i);
2487 }
2488
Chris Mayer328d8212018-12-11 14:16:18 +01002489 if (vp_swizzle_struct) {
2490 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002491 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2492 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2493 " does "
2494 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2495 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002496 }
2497 }
2498
Petr Krausb3fcdb42018-01-09 22:09:09 +01002499 // validate the VkViewports
2500 if (!has_dynamic_viewport && viewport_state.pViewports) {
2501 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2502 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002503 const char *fn_name = "vkCreateGraphicsPipelines";
2504 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2505 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2506 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002507 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002508 }
2509 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002510
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002511 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002512 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2513 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2514 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2515 "VK_NV_clip_space_w_scaling extension is not enabled.",
2516 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002517 }
2518
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002519 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002520 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2521 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2522 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2523 "VK_EXT_discard_rectangles extension is not enabled.",
2524 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002525 }
2526
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002527 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002528 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2529 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2530 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2531 "VK_EXT_sample_locations extension is not enabled.",
2532 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002533 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002534
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002535 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002536 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2537 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2538 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2539 "VK_NV_scissor_exclusive extension is not enabled.",
2540 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002541 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002542
2543 if (coarse_sample_order_struct &&
2544 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2545 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002546 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2547 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2548 "] "
2549 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2550 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2551 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002552 }
2553
2554 if (coarse_sample_order_struct) {
2555 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002556 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002557 }
2558 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002559
2560 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2561 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002562 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2563 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2564 "] "
2565 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2566 ") "
2567 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2568 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002569 }
2570 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002571 skip |= LogError(
2572 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002573 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2574 "] "
2575 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2576 i);
2577 }
2578 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002579 }
2580
2581 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002582 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2583 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2584 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2585 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002586 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002587 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002588 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002589 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2590 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002591 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002592 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002593 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002594 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002595 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002596 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002597 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002598 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2599 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002600
2601 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002602 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002603 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002604 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002605
2606 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002607 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002608 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2609 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2610
2611 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002612 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002613 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2614 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002615 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002616 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002618 skip |= validate_flags(
2619 "vkCreateGraphicsPipelines",
2620 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2621 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002622 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002623
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002624 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002625 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002626 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2627 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2628
2629 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002630 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002631 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2632 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2633
2634 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002635 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002636 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2637 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2638 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002639 }
John Zulauf7acac592017-11-06 11:15:53 -07002640 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002641 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002642 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2643 "vkCreateGraphicsPipelines(): parameter "
2644 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2645 i);
John Zulauf7acac592017-11-06 11:15:53 -07002646 }
2647 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2648 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2649 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002650 skip |= LogError(
2651 device,
2652
Dave Houlton413a6782018-05-22 13:01:54 -06002653 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002654 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002655 }
2656 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002657
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002658 const auto *line_state =
2659 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002660
2661 if (line_state) {
2662 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2663 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2664 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2665 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002666 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2667 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2668 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2669 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002670 }
2671 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2672 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002673 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2674 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2675 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2676 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002677 }
2678 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2679 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002680 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2681 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2682 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2683 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002684 }
2685 }
2686 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2687 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2688 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002689 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2690 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2691 "range [1,256].",
2692 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002693 }
2694 }
2695 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002696 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002697 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2698 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002699 skip |=
2700 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2701 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2702 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2703 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002704 }
2705 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2706 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002707 skip |=
2708 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2709 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2710 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2711 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002712 }
2713 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2714 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002715 skip |=
2716 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2717 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2718 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2719 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002720 }
2721 if (line_state->stippledLineEnable) {
2722 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2723 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002724 skip |=
2725 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2726 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2727 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2728 "stippledRectangularLines feature.",
2729 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002730 }
2731 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2732 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002733 skip |=
2734 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2735 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2736 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2737 "stippledBresenhamLines feature.",
2738 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002739 }
2740 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2741 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002742 skip |=
2743 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2744 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2745 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2746 "stippledSmoothLines feature.",
2747 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002748 }
2749 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2750 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002751 skip |=
2752 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2753 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2754 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2755 "stippledRectangularLines and strictLines features.",
2756 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002757 }
2758 }
2759 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002760 }
2761
Petr Krause91f7a12017-12-14 20:57:36 +01002762 bool uses_color_attachment = false;
2763 bool uses_depthstencil_attachment = false;
2764 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002765 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002766 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2767 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002768 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002769 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002770 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002771 }
2772 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002773 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002774 }
Petr Krause91f7a12017-12-14 20:57:36 +01002775 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002776 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002777 }
2778
2779 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002780 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002781 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002782 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002783 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002784 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002785
2786 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002787 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002788 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002789 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002790
2791 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002792 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002793 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2794 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2795
2796 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002797 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002798 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2799 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2800
2801 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002802 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002803 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2804 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002805 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002806
2807 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002808 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002809 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2810 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2811
2812 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002813 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002814 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2815 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2816
2817 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002818 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002819 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2820 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002821 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822
2823 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002824 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002825 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2826 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002827 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002828
2829 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002830 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002831 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2832 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002833 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002834
2835 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002836 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002837 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2838 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002839 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002840
2841 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002842 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002843 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2844 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002845 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002846
2847 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002848 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002849 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2850 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002851 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852
2853 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002854 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002855 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2856 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002857 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002858
2859 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002860 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002861 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2862 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002863 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002864
2865 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002866 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002867 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2868 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2869 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870 }
2871 }
2872
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002873 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002874 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2875
Petr Krause91f7a12017-12-14 20:57:36 +01002876 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002877 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2878 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2879 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2880 pCreateInfos[i].pColorBlendState,
2881 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2882 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2883
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002884 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002885 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002886 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2887 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002888 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2889 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002890 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2891 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892
2893 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002894 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002895 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002896 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897
2898 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002899 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2901 pCreateInfos[i].pColorBlendState->logicOpEnable);
2902
2903 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002904 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002905 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2906 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002907 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002908 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002909
2910 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002911 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2912 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002913 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002914 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002915 ParameterName::IndexVector{i, attachment_index}),
2916 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002917
2918 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002919 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002920 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002921 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002922 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002923 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002924 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002925
2926 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002927 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002928 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002929 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002930 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002931 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002932 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002933
2934 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002935 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002936 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002937 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002938 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002939 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002940 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002941
2942 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002943 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002945 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002946 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002947 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002948 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002949
2950 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002951 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002952 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002953 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002954 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002955 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002956 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002957
2958 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002959 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002960 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002961 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002963 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002964 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965
2966 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002967 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002969 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002971 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002972 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973 }
2974 }
2975
2976 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002977 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002978 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2979 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2980 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002981 }
2982
2983 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2984 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2985 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002986 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002988 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2989 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002990 }
2991 }
2992 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002993
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002994 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
2995 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01002996 if (pCreateInfos[i].basePipelineIndex != -1) {
2997 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002998 skip |=
2999 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003000 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003001 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003002 "and pCreateInfos->basePipelineIndex is not -1.",
3003 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003004 }
3005 }
3006
Petr Kraus9752aae2017-11-24 03:05:50 +01003007 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3008 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003009 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003010 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003011 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003012 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3013 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003014 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003015 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003016 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003017 skip |=
3018 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
3019 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
3020 "index into the pCreateInfos array, of size %d.",
3021 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003022 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003023 }
3024 }
3025
Petr Kraus9752aae2017-11-24 03:05:50 +01003026 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003027 if (!device_extensions.vk_nv_fill_rectangle) {
3028 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3029 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003030 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3031 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3032 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3033 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003034 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3035 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003036 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003037 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003038 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
3039 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3040 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003041 }
3042 } else {
3043 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3044 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3045 (physical_device_features.fillModeNonSolid == false)) {
3046 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003047 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3048 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003049 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
3050 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3051 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003052 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003053 }
Petr Kraus299ba622017-11-24 03:09:03 +01003054
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003055 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003056 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003057 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3058 "The line width state is static (pCreateInfos[%" PRIu32
3059 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3060 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3061 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3062 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003063 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003064 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003065
3066 // Validate no flags not allowed are used
3067 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003068 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
3069 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3070 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3071 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003072 }
3073 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003074 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
3075 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3076 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3077 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003078 }
3079 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3080 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07003081 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3082 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3083 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003084 }
3085 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3086 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07003087 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3088 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3089 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003090 }
3091 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3092 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07003093 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3094 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3095 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003096 }
3097 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3098 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003099 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3100 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3101 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003102 }
3103 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3104 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003105 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3106 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3107 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003108 }
3109 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3110 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003111 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3112 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3113 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003114 }
3115 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3116 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003117 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3118 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3119 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003120 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003121 }
3122 }
3123
3124 return skip;
3125}
3126
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003127bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3128 uint32_t createInfoCount,
3129 const VkComputePipelineCreateInfo *pCreateInfos,
3130 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003131 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003133 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003134 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003135 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003136 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003137 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003138 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003139 skip |=
3140 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3141 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3142 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3143 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003144 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003145
3146 // Make sure compute stage is selected
3147 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003148 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3149 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3150 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003151 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003152
sfricke-samsungeb549012021-04-16 01:25:51 -07003153 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3154 // Validate no flags not allowed are used
3155 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3156 skip |= LogError(
3157 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3158 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3159 i, flags);
3160 }
3161 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3162 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3163 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3164 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3165 i, flags);
3166 }
3167 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3168 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3169 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3170 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3171 i, flags);
3172 }
3173 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3174 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3175 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3176 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3177 i, flags);
3178 }
3179 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3180 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3181 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3182 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3183 i, flags);
3184 }
3185 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3186 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3187 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3188 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3189 i, flags);
3190 }
3191 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3192 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3193 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3194 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3195 i, flags);
3196 }
3197 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3198 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3199 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3200 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3201 i, flags);
3202 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003203 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3204 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
3205 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3206 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3207 i, flags);
3208 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003209 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3210 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3211 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3212 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3213 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003214 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003215 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003216 return skip;
3217}
3218
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003219bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003220 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003221 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003222
3223 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003224 const auto &features = physical_device_features;
3225 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003226
John Zulauf71968502017-10-26 13:51:15 -06003227 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3228 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003229 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3230 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3231 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3232 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003233 }
3234
3235 // Anistropy cannot be enabled in sampler unless enabled as a feature
3236 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003237 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3238 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3239 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003240 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003241 }
John Zulauf71968502017-10-26 13:51:15 -06003242
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003243 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3244 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003245 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3246 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3247 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3248 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003249 }
3250 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003251 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3252 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3253 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3254 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003255 }
3256 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003257 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3258 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3259 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3260 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003261 }
3262 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3263 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3264 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3265 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003266 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3267 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3268 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3269 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3270 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3271 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003272 }
3273 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003274 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3275 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3276 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003277 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003278 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003279 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3280 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3281 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003282 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003283 }
3284
3285 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3286 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003287 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3288 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003289 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003290 if (sampler_reduction != nullptr) {
3291 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3292 skip |= LogError(
3293 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3294 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3295 }
3296 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003297 }
3298
3299 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3300 // valid VkBorderColor value
3301 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3302 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3303 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003304 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3305 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003306 }
3307
John Zulauf275805c2017-10-26 15:34:49 -06003308 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003309 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003310 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3311 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003312 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3313 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3314 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003315 }
3316 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003317
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003318 // Check for valid Lod range
3319 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003320 skip |=
3321 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3322 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003323 }
3324
3325 // Check mipLodBias to device limit
3326 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003327 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3328 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3329 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003330 }
3331
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003332 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003333 if (sampler_conversion != nullptr) {
3334 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3335 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3336 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3337 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003338 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003339 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003340 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3341 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3342 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3343 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3344 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3345 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3346 }
3347 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003348
3349 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3350 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3351 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3352 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3353 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3354 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3355 }
3356 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3357 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3358 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3359 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3360 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3361 }
3362 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3363 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3364 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3365 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3366 pCreateInfo->minLod, pCreateInfo->maxLod);
3367 }
3368 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3369 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3370 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3371 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3372 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3373 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3374 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3375 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3376 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3377 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3378 }
3379 if (pCreateInfo->anisotropyEnable) {
3380 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3381 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3382 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3383 }
3384 if (pCreateInfo->compareEnable) {
3385 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3386 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3387 "pCreateInfo->compareEnable must be VK_FALSE");
3388 }
3389 if (pCreateInfo->unnormalizedCoordinates) {
3390 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3391 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3392 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3393 }
3394 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003395 }
3396
Tony-LunarG7337b312020-04-15 16:40:25 -06003397 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3398 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3399 if (!device_extensions.vk_ext_custom_border_color) {
3400 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3401 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3402 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3403 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003404 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003405 if (!custom_create_info) {
3406 skip |=
3407 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3408 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3409 "struct in pNext chain.\n",
3410 string_VkBorderColor(pCreateInfo->borderColor));
3411 } else {
3412 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3413 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3414 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3415 !FormatIsSampledFloat(custom_create_info->format)))) {
3416 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3417 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3418 "whose type does not match\n",
3419 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3420 ;
3421 }
3422 }
3423 }
3424
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003425 return skip;
3426}
3427
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003428bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3429 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3430 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003431 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003432 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433
3434 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3435 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3436 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3437 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003438 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3439 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3440 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3441 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3442 ++descriptor_index) {
3443 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003444 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003445 "vkCreateDescriptorSetLayout: required parameter "
3446 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3447 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003448 }
3449 }
3450 }
3451
3452 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3453 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3454 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003455 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3456 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3457 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3458 "values.",
3459 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003460 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003461
3462 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3463 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3464 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3465 skip |=
3466 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3467 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3468 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3469 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3470 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3471 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003472 }
3473 }
3474 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003475 return skip;
3476}
3477
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003478bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3479 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003480 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003481 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3482 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3483 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003484 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3485 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003486}
3487
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003488bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3489 const VkWriteDescriptorSet *pDescriptorWrites,
3490 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003491 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003492
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003493 if (pDescriptorWrites != NULL) {
3494 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3495 // descriptorCount must be greater than 0
3496 if (pDescriptorWrites[i].descriptorCount == 0) {
3497 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003498 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3499 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003500 }
3501
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003502 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3503 if (validateDstSet) {
3504 // dstSet must be a valid VkDescriptorSet handle
3505 skip |= validate_required_handle(vkCallingFunction,
3506 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3507 pDescriptorWrites[i].dstSet);
3508 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003509
3510 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3511 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3512 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3513 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3514 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3515 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3516 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003517 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3518 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003519 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003520 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3521 "%s(): if pDescriptorWrites[%d].descriptorType is "
3522 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3523 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3524 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3525 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003526 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3527 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003528 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3529 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003530 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3531 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003532 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003533 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3534 ParameterName::IndexVector{i, descriptor_index}),
3535 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003536 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003537 }
3538 }
3539 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3540 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3541 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3542 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3543 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3544 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3545 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003546 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003547 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003548 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3549 "%s(): if pDescriptorWrites[%d].descriptorType is "
3550 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3551 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3552 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3553 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003554 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003555 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003556 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003557 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003558 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3559 ++descriptor_index) {
3560 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3561 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3562 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003563 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3564 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003565 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003566 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3567 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003568 }
3569 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003570 }
3571 }
3572 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3573 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003574 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003575 }
3576
3577 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3578 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003579 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003580 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3581 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003582 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003583 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003584 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3585 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3586 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003587 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003588 }
3589 }
3590 }
3591 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3592 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003593 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003594 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3595 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003596 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003597 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003598 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3599 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3600 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003601 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003602 }
3603 }
3604 }
3605 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003606 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3607 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003608 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003609 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003610 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3611 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3612 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3613 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3614 "accelerationStructureCount %d member equals descriptorCount %d.",
3615 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3616 pDescriptorWrites[i].descriptorCount);
3617 }
3618 // further checks only if we have right structtype
3619 if (pnext_struct) {
3620 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3621 skip |= LogError(
3622 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3623 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3624 ".",
3625 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003626 }
sourav parmarbcee7512020-12-28 14:34:49 -08003627 if (pnext_struct->accelerationStructureCount == 0) {
3628 skip |= LogError(device,
3629 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003630 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003631 }
3632 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003633 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003634 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3635 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3636 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3637 skip |= LogError(device,
3638 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3639 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003640 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003641 }
3642 }
3643 }
sourav parmarbcee7512020-12-28 14:34:49 -08003644 }
3645 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003646 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003647 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3648 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3649 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3650 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3651 "accelerationStructureCount %d member equals descriptorCount %d.",
3652 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3653 pDescriptorWrites[i].descriptorCount);
3654 }
3655 // further checks only if we have right structtype
3656 if (pnext_struct) {
3657 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3658 skip |= LogError(
3659 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3660 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3661 ".",
3662 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003663 }
sourav parmarbcee7512020-12-28 14:34:49 -08003664 if (pnext_struct->accelerationStructureCount == 0) {
3665 skip |= LogError(device,
3666 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003667 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003668 }
3669 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003670 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003671 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3672 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3673 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3674 skip |= LogError(device,
3675 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3676 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003677 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003678 }
3679 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003680 }
3681 }
3682 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003683 }
3684 }
3685 return skip;
3686}
3687
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003688bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3689 const VkWriteDescriptorSet *pDescriptorWrites,
3690 uint32_t descriptorCopyCount,
3691 const VkCopyDescriptorSet *pDescriptorCopies) const {
3692 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3693}
3694
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003695bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003696 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003697 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003698 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3699}
3700
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003701bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3702 const VkAllocationCallbacks *pAllocator,
3703 VkRenderPass *pRenderPass) const {
3704 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3705}
3706
Mike Schuchardt2df08912020-12-15 16:28:09 -08003707bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003708 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003709 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003710 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3711}
3712
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003713bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3714 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003715 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003716 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003717
3718 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3719 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3720 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003721 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3722 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003723 return skip;
3724}
3725
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003726bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003727 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003728 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003729
3730 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3731 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003732 bool cb_is_secondary;
3733 {
3734 auto lock = cb_read_lock();
3735 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3736 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003737
Tony-LunarG3c287f62020-12-17 12:39:49 -07003738 if (cb_is_secondary) {
3739 // Implicit VUs
3740 // validate only sType here; pointer has to be validated in core_validation
3741 const bool k_not_required = false;
3742 const char *k_no_vuid = nullptr;
3743 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3744 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003745 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3746 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003747
Tony-LunarG3c287f62020-12-17 12:39:49 -07003748 if (info) {
3749 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003750 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3751 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003752 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003753 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3754 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3755 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3756 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003757
Tony-LunarG3c287f62020-12-17 12:39:49 -07003758 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003759
Tony-LunarG3c287f62020-12-17 12:39:49 -07003760 // Explicit VUs
3761 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003762 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003763 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3764 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3765 cmd_name);
3766 }
3767
3768 if (physical_device_features.inheritedQueries) {
3769 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003770 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3771 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3772 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003773 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003774 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003775 }
3776
3777 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003778 skip |=
3779 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3780 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3781 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3782 } else { // !pipelineStatisticsQuery
3783 skip |=
3784 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3785 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003786 }
3787
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003788 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003789 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003790 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003791 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3792 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3793 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003794 commandBuffer,
3795 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003796 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3797 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3798 }
Petr Kraus139757b2019-08-15 17:19:33 +02003799 }
ziga-lunarg9d019132021-07-19 01:05:31 +02003800
3801 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
3802 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
3803 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
3804 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
3805 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
3806 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
3807 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
3808 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
3809 }
Petr Kraus139757b2019-08-15 17:19:33 +02003810 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003811 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003812 return skip;
3813}
3814
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003815bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003816 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003817 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003818
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003819 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003820 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003821 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3822 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3823 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003824 }
3825 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003826 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3827 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3828 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003829 }
3830 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003831 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003832 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003833 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3834 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3835 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3836 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003837 }
3838 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003839
3840 if (pViewports) {
3841 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3842 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003843 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003844 skip |= manual_PreCallValidateViewport(
3845 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003846 }
3847 }
3848
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003849 return skip;
3850}
3851
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003852bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003853 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003854 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003855
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003856 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003857 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003858 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3859 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3860 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003861 }
3862 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003863 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3864 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3865 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003866 }
3867 } else { // multiViewport enabled
3868 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003869 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003870 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3871 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3872 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3873 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003874 }
3875 }
3876
Petr Kraus6260f0a2018-02-27 21:15:55 +01003877 if (pScissors) {
3878 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3879 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003880
Petr Kraus6260f0a2018-02-27 21:15:55 +01003881 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003882 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3883 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3884 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003885 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003886
Petr Kraus6260f0a2018-02-27 21:15:55 +01003887 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003888 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3889 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3890 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003891 }
3892
3893 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3894 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003895 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3896 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3897 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3898 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003899 }
3900
3901 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3902 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003903 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3904 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3905 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3906 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003907 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003908 }
3909 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003910
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003911 return skip;
3912}
3913
Jeff Bolz5c801d12019-10-09 10:38:45 -05003914bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003915 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003916
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003917 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003918 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3919 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003920 }
3921
3922 return skip;
3923}
3924
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003925bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003926 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003927 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003928
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003929 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003930 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003931 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3932 }
3933 if (drawCount > device_limits.maxDrawIndirectCount) {
3934 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003935 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3936 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003937 }
3938 return skip;
3939}
3940
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003941bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003942 VkDeviceSize offset, uint32_t drawCount,
3943 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003944 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003945 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003946 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3947 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3948 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003949 }
3950 if (drawCount > device_limits.maxDrawIndirectCount) {
3951 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003952 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3953 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003954 }
3955 return skip;
3956}
3957
sfricke-samsungf692b972020-05-02 08:00:45 -07003958bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3959 VkDeviceSize countBufferOffset, bool khr) const {
3960 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003961 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003962 if (offset & 3) {
3963 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003964 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003965 }
3966
3967 if (countBufferOffset & 3) {
3968 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003969 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003970 countBufferOffset);
3971 }
3972 return skip;
3973}
3974
3975bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3976 VkDeviceSize offset, VkBuffer countBuffer,
3977 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3978 uint32_t stride) const {
3979 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3980}
3981
3982bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3983 VkDeviceSize offset, VkBuffer countBuffer,
3984 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3985 uint32_t stride) const {
3986 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3987}
3988
3989bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3990 VkDeviceSize countBufferOffset, bool khr) const {
3991 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003992 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003993 if (offset & 3) {
3994 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003995 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003996 }
3997
3998 if (countBufferOffset & 3) {
3999 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004000 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004001 countBufferOffset);
4002 }
4003 return skip;
4004}
4005
4006bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4007 VkDeviceSize offset, VkBuffer countBuffer,
4008 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4009 uint32_t stride) const {
4010 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4011}
4012
4013bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4014 VkDeviceSize offset, VkBuffer countBuffer,
4015 VkDeviceSize countBufferOffset,
4016 uint32_t maxDrawCount, uint32_t stride) const {
4017 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4018}
4019
Tony-LunarG4490de42021-06-21 15:49:19 -06004020bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4021 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4022 uint32_t firstInstance, uint32_t stride) const {
4023 bool skip = false;
4024 if (stride & 3) {
4025 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4026 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4027 }
4028 if (drawCount && nullptr == pVertexInfo) {
4029 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4030 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4031 "one or more valid instances of VkMultiDrawInfoEXT structures");
4032 }
4033 return skip;
4034}
4035
4036bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4037 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4038 uint32_t instanceCount, uint32_t firstInstance,
4039 uint32_t stride, const int32_t *pVertexOffset) const {
4040 bool skip = false;
4041 if (stride & 3) {
4042 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4043 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4044 }
4045 if (drawCount && nullptr == pIndexInfo) {
4046 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4047 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4048 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4049 }
4050 return skip;
4051}
4052
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004053bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4054 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004055 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004056 bool skip = false;
4057 for (uint32_t rect = 0; rect < rectCount; rect++) {
4058 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004059 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
4060 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004061 }
sfricke-samsung10867682020-04-25 02:20:39 -07004062 if (pRects[rect].rect.extent.width == 0) {
4063 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
4064 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
4065 }
4066 if (pRects[rect].rect.extent.height == 0) {
4067 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
4068 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
4069 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004070 }
4071 return skip;
4072}
4073
Andrew Fobel3abeb992020-01-20 16:33:22 -05004074bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4075 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4076 VkImageFormatProperties2 *pImageFormatProperties,
4077 const char *apiName) const {
4078 bool skip = false;
4079
4080 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004081 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004082 if (image_stencil_struct != nullptr) {
4083 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4084 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4085 // No flags other than the legal attachment bits may be set
4086 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4087 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004088 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4089 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4090 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4091 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4092 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004093 }
4094 }
4095 }
4096 }
4097
4098 return skip;
4099}
4100
4101bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4102 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4103 VkImageFormatProperties2 *pImageFormatProperties) const {
4104 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4105 "vkGetPhysicalDeviceImageFormatProperties2");
4106}
4107
4108bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4109 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4110 VkImageFormatProperties2 *pImageFormatProperties) const {
4111 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4112 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4113}
4114
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004115bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4116 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4117 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4118 bool skip = false;
4119
4120 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4121 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4122 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4123 }
4124
4125 return skip;
4126}
4127
sfricke-samsung3999ef62020-02-09 17:05:59 -08004128bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4129 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4130 bool skip = false;
4131
4132 if (pRegions != nullptr) {
4133 for (uint32_t i = 0; i < regionCount; i++) {
4134 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004135 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4136 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004137 }
4138 }
4139 }
4140 return skip;
4141}
4142
Jeff Leger178b1e52020-10-05 12:22:23 -04004143bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4144 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4145 bool skip = false;
4146
4147 if (pCopyBufferInfo->pRegions != nullptr) {
4148 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4149 if (pCopyBufferInfo->pRegions[i].size == 0) {
4150 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4151 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4152 }
4153 }
4154 }
4155 return skip;
4156}
4157
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004158bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004159 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4160 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004161 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004162
4163 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004164 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4165 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4166 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004167 }
4168
4169 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004170 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4171 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4172 "), must be greater than zero and less than or equal to 65536.",
4173 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004174 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004175 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4176 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4177 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004178 }
4179 return skip;
4180}
4181
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004182bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004183 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004184 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004185
4186 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004187 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4188 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4189 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004190 }
4191
4192 if (size != VK_WHOLE_SIZE) {
4193 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004194 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004195 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4196 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004197 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004198 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4199 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004200 }
4201 }
4202 return skip;
4203}
4204
sfricke-samsunga1d00272021-03-10 21:37:41 -08004205bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004206 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004207
4208 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004209 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4210 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4211 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4212 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004213 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004214 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4215 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4216 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004217 }
4218
4219 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4220 // queueFamilyIndexCount uint32_t values
4221 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004222 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004223 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004224 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004225 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4226 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004227 }
4228 }
4229
Dave Houlton413a6782018-05-22 13:01:54 -06004230 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004231 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004232
sfricke-samsunga1d00272021-03-10 21:37:41 -08004233 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4234 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4235 if (format_list_info) {
4236 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4237 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4238 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4239 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4240 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4241 func_name, viewFormatCount);
4242 }
4243
4244 // Using the first format, compare the rest of the formats against it that they are compatible
4245 for (uint32_t i = 1; i < viewFormatCount; i++) {
4246 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4247 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4248 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4249 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4250 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4251 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4252 string_VkFormat(format_list_info->pViewFormats[i]));
4253 }
4254 }
4255 }
4256
4257 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4258 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4259 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4260 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4261 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4262 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4263 func_name);
4264 } else {
4265 if (format_list_info == nullptr) {
4266 skip |= LogError(
4267 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4268 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4269 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4270 func_name);
4271 } else if (format_list_info->viewFormatCount == 0) {
4272 skip |= LogError(
4273 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4274 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4275 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4276 func_name);
4277 } else {
4278 bool found_base_format = false;
4279 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4280 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4281 found_base_format = true;
4282 break;
4283 }
4284 }
4285 if (!found_base_format) {
4286 skip |=
4287 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4288 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4289 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4290 "pCreateInfo->imageFormat.",
4291 func_name);
4292 }
4293 }
4294 }
4295 }
4296 }
4297 return skip;
4298}
4299
4300bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4301 const VkAllocationCallbacks *pAllocator,
4302 VkSwapchainKHR *pSwapchain) const {
4303 bool skip = false;
4304 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4305 return skip;
4306}
4307
4308bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4309 const VkSwapchainCreateInfoKHR *pCreateInfos,
4310 const VkAllocationCallbacks *pAllocator,
4311 VkSwapchainKHR *pSwapchains) const {
4312 bool skip = false;
4313 if (pCreateInfos) {
4314 for (uint32_t i = 0; i < swapchainCount; i++) {
4315 std::stringstream func_name;
4316 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4317 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4318 }
4319 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004320 return skip;
4321}
4322
Jeff Bolz5c801d12019-10-09 10:38:45 -05004323bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004324 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004325
4326 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004327 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004328 if (present_regions) {
4329 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004330 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004331 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4332 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004333 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004334 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4335 "extension swapchainCount is %i. These values must be equal.",
4336 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004337 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004338 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004339 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4340 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004341 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4342 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4343 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004344 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004345 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004346 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004347 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004348 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004349 }
4350 }
4351
4352 return skip;
4353}
4354
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004355bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4356 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4357 const VkAllocationCallbacks *pAllocator,
4358 VkDisplayModeKHR *pMode) const {
4359 bool skip = false;
4360
4361 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4362 if (display_mode_parameters.visibleRegion.width == 0) {
4363 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4364 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4365 }
4366 if (display_mode_parameters.visibleRegion.height == 0) {
4367 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4368 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4369 }
4370 if (display_mode_parameters.refreshRate == 0) {
4371 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4372 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4373 }
4374
4375 return skip;
4376}
4377
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004378#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004379bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4380 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4381 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004382 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004383 bool skip = false;
4384
4385 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004386 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4387 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004388 }
4389
4390 return skip;
4391}
4392#endif // VK_USE_PLATFORM_WIN32_KHR
4393
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004394bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004395 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004396 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004397 bool skip = false;
4398
4399 if (pCreateInfo) {
4400 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004401 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4402 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004403 }
4404
4405 if (pCreateInfo->pPoolSizes) {
4406 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4407 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004408 skip |= LogError(
4409 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004410 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004411 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004412 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4413 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004414 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4415 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4416 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4417 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4418 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004419 }
Petr Krausc8655be2017-09-27 18:56:51 +02004420 }
4421 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004422
4423 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4424 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4425 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4426 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4427 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4428 }
Petr Krausc8655be2017-09-27 18:56:51 +02004429 }
4430
4431 return skip;
4432}
4433
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004434bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004435 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004436 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004437
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004438 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004439 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004440 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4441 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4442 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004443 }
4444
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004445 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004446 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004447 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4448 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4449 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004450 }
4451
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004452 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004453 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004454 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4455 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4456 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004457 }
4458
4459 return skip;
4460}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004461
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004462bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004463 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004464 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004465
4466 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004467 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4468 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004469 }
4470 return skip;
4471}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004472
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004473bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4474 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004475 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004476 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004477
4478 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004479 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004480 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004481 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4482 "vkCmdDispatch(): baseGroupX (%" PRIu32
4483 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4484 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004485 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004486 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4487 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4488 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4489 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004490 }
4491
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004492 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004493 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004494 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4495 "vkCmdDispatch(): baseGroupY (%" PRIu32
4496 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4497 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004498 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004499 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4500 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4501 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4502 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004503 }
4504
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004505 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004506 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004507 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4508 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4509 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4510 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004511 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004512 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4513 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4514 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4515 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004516 }
4517
4518 return skip;
4519}
4520
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004521bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4522 VkPipelineBindPoint pipelineBindPoint,
4523 VkPipelineLayout layout, uint32_t set,
4524 uint32_t descriptorWriteCount,
4525 const VkWriteDescriptorSet *pDescriptorWrites) const {
4526 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4527}
4528
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004529bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4530 uint32_t firstExclusiveScissor,
4531 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004532 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004533 bool skip = false;
4534
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004535 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004536 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004537 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004538 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4539 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4540 ") is not 0.",
4541 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004542 }
4543 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004544 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004545 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4546 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4547 ") is not 1.",
4548 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004549 }
4550 } else { // multiViewport enabled
4551 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004552 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004553 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4554 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4555 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4556 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004557 }
4558 }
4559
Jeff Bolz3e71f782018-08-29 23:15:45 -05004560 if (pExclusiveScissors) {
4561 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4562 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4563
4564 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004565 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4566 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4567 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004568 }
4569
4570 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004571 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4572 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4573 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004574 }
4575
4576 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4577 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004578 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4579 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4580 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4581 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004582 }
4583
4584 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4585 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004586 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4587 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4588 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4589 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004590 }
4591 }
4592 }
4593
4594 return skip;
4595}
4596
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004597bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4598 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004599 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004600 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004601 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4602 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4603 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4604 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4605 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4606 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004607 }
4608
4609 return skip;
4610}
4611
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004612bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4613 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004614 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004615 bool skip = false;
4616
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004617 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004618 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004619 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004620 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4621 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4622 ") is not 0.",
4623 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004624 }
4625 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004626 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004627 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4628 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4629 ") is not 1.",
4630 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004631 }
4632 }
4633
Jeff Bolz9af91c52018-09-01 21:53:57 -05004634 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004635 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004636 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4637 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4638 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4639 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004640 }
4641
4642 return skip;
4643}
4644
Jeff Bolz5c801d12019-10-09 10:38:45 -05004645bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4646 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4647 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004648 bool skip = false;
4649
Dave Houlton142c4cb2018-10-17 15:04:41 -06004650 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004651 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4652 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4653 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004654 }
4655
4656 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004657 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004658 }
4659
4660 return skip;
4661}
4662
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004663bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004664 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004665 bool skip = false;
4666
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004667 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004668 skip |= LogError(
4669 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004670 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4671 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004672 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004673 }
4674
4675 return skip;
4676}
4677
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004678bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4679 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004680 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004681 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004682 static const int condition_multiples = 0b0011;
4683 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004684 skip |= LogError(
4685 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004686 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004687 }
Lockee1c22882019-06-10 16:02:54 -06004688 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004689 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4690 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4691 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4692 stride);
Lockee1c22882019-06-10 16:02:54 -06004693 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004694 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004695 skip |= LogError(
4696 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4697 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004698 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004699 if (drawCount > device_limits.maxDrawIndirectCount) {
4700 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004701 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4702 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004703 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004704 return skip;
4705}
4706
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004707bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4708 VkDeviceSize offset, VkBuffer countBuffer,
4709 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004710 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004711 bool skip = false;
4712
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004713 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004714 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4715 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4716 "), is not a multiple of 4.",
4717 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004718 }
4719
4720 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004721 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4722 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4723 "), is not a multiple of 4.",
4724 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004725 }
4726
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004727 return skip;
4728}
4729
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004730bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004731 const VkAllocationCallbacks *pAllocator,
4732 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004733 bool skip = false;
4734
4735 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4736 if (pCreateInfo != nullptr) {
4737 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4738 // VkQueryPipelineStatisticFlagBits values
4739 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4740 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004741 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4742 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4743 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4744 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004745 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004746 if (pCreateInfo->queryCount == 0) {
4747 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4748 "vkCreateQueryPool(): queryCount must be greater than zero.");
4749 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004750 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004751 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004752}
4753
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004754bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4755 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004756 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004757 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4758 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004759}
4760
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004761void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004762 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4763 VkResult result) {
4764 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004765 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004766}
4767
Mike Schuchardt2df08912020-12-15 16:28:09 -08004768void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004769 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4770 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004771 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004772 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004773 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004774}
4775
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004776void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4777 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004778 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004779 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004780 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004781}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004782
Tony-LunarG3c287f62020-12-17 12:39:49 -07004783void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004784 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004785 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4786 auto lock = cb_write_lock();
4787 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004788 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004789 }
4790 }
4791}
4792
4793void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004794 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004795 auto lock = cb_write_lock();
4796 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4797 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4798 }
4799}
4800
4801void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004802 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004803 auto lock = cb_write_lock();
4804 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4805 if (item->second == commandPool) {
4806 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004807 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004808 ++item;
4809 }
4810 }
4811}
4812
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004813bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004814 const VkAllocationCallbacks *pAllocator,
4815 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004816 bool skip = false;
4817
4818 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004819 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004820 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004821 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4822 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004823 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004824
4825 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004826 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004827 if (flags_info) {
4828 flags = flags_info->flags;
4829 }
4830
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004831 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004832 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004833 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004834 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4835 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004836 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004837 }
4838
4839#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004840 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004841#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004842 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4843 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004844#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004845 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004846#endif
4847
4848 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004849 skip |= LogError(
4850 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004851 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4852 }
4853 if (
4854#ifdef VK_USE_PLATFORM_WIN32_KHR
4855 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4856#endif
4857 (import_memory_fd && import_memory_fd->handleType) ||
4858#ifdef VK_USE_PLATFORM_ANDROID_KHR
4859 (import_memory_ahb && import_memory_ahb->buffer) ||
4860#endif
4861 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004862 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4863 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004864 }
4865 }
4866
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02004867 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
4868 if (export_memory) {
4869 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
4870 if (export_memory_nv) {
4871 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4872 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4873 "VkExportMemoryAllocateInfoNV");
4874 }
4875#ifdef VK_USE_PLATFORM_WIN32_KHR
4876 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
4877 if (export_memory_win32_nv) {
4878 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4879 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4880 "VkExportMemoryWin32HandleInfoNV");
4881 }
4882#endif
4883 }
4884
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004885 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004886 VkBool32 capture_replay = false;
4887 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004888 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004889 if (vulkan_12_features) {
4890 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4891 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4892 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004893 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004894 if (bda_features) {
4895 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4896 buffer_device_address = bda_features->bufferDeviceAddress;
4897 }
4898 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004899 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004900 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004901 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004902 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004903 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004904 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004905 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004906 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004907 }
4908 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004909 }
4910 return skip;
4911}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004912
Jason Macnak192fa0e2019-07-26 15:07:16 -07004913bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004914 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004915 bool skip = false;
4916
4917 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4918 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4919 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004920 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004921 } else {
4922 uint32_t vertex_component_size = 0;
4923 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4924 vertex_component_size = 4;
4925 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4926 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4927 vertex_component_size = 2;
4928 }
4929 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004930 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004931 }
4932 }
4933
4934 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4935 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004936 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004937 } else {
4938 uint32_t index_element_size = 0;
4939 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4940 index_element_size = 4;
4941 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4942 index_element_size = 2;
4943 }
4944 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004945 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004946 }
4947 }
4948 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4949 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004950 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004951 }
4952 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004953 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004954 }
4955 }
4956
4957 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004958 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004959 }
4960
4961 return skip;
4962}
4963
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004964bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4965 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004966 bool skip = false;
4967
4968 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004969 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004970 }
4971 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004972 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004973 }
4974
4975 return skip;
4976}
4977
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004978bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4979 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004980 bool skip = false;
4981 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004982 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004983 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004984 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004985 }
4986 return skip;
4987}
4988
4989bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004990 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004991 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004992 bool skip = false;
4993 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004994 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4995 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4996 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004997 }
4998 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004999 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5000 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5001 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005002 }
5003 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5004 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005005 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5006 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5007 "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 -07005008 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005009 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005010 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005011 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5012 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005013 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5014 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005015 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005016 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005017 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5018 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5019 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005020 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005021 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005022 uint64_t total_triangle_count = 0;
5023 for (uint32_t i = 0; i < info.geometryCount; i++) {
5024 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005025
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005026 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005027
Jason Macnak5c954952019-07-09 15:46:12 -07005028 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5029 continue;
5030 }
5031 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5032 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005033 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005034 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5035 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5036 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005037 }
5038 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005039 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5040 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5041 for (uint32_t i = 1; i < info.geometryCount; i++) {
5042 const VkGeometryNV &geometry = info.pGeometries[i];
5043 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005044 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005045 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
5046 "info.pGeometries[0].geometryType.",
5047 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005048 }
5049 }
5050 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005051 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5052 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5053 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5054 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5055 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5056 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5057 }
5058 }
5059 skip |=
5060 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005061 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005062 return skip;
5063}
5064
Ricardo Garciaa4935972019-02-21 17:43:18 +01005065bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5066 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005067 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005068 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005069 if (pCreateInfo) {
5070 if ((pCreateInfo->compactedSize != 0) &&
5071 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005072 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5073 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5074 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5075 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005076 }
Jason Macnak5c954952019-07-09 15:46:12 -07005077
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005078 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005079 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005080 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005081 return skip;
5082}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005083
Jeff Bolz5c801d12019-10-09 10:38:45 -05005084bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5085 const VkAccelerationStructureInfoNV *pInfo,
5086 VkBuffer instanceData, VkDeviceSize instanceOffset,
5087 VkBool32 update, VkAccelerationStructureNV dst,
5088 VkAccelerationStructureNV src, VkBuffer scratch,
5089 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005090 bool skip = false;
5091
5092 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005093 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005094 }
5095
5096 return skip;
5097}
5098
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005099bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5100 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5101 VkAccelerationStructureKHR *pAccelerationStructure) const {
5102 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005103 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005104 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005105 if (!acceleration_structure_features ||
5106 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5107 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5108 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5109 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005110 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005111 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5112 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005113 (acceleration_structure_features &&
5114 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005115 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005116 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5117 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5118 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5119 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005120 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005121 if (pCreateInfo->deviceAddress &&
5122 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5123 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5124 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5125 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5126 }
5127 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5128 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005129 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005130 }
sourav parmar83c31b12020-05-06 12:30:54 -07005131 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005132 return skip;
5133}
5134
Jason Macnak5c954952019-07-09 15:46:12 -07005135bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5136 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005137 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005138 bool skip = false;
5139 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005140 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5141 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005142 }
5143 return skip;
5144}
5145
sourav parmarcd5fb182020-07-17 12:58:44 -07005146bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5147 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5148 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5149 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005150 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005151 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
5152 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005153 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005154 }
5155 return skip;
5156}
5157
Peter Chen85366392019-05-14 15:20:11 -04005158bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5159 uint32_t createInfoCount,
5160 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5161 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005162 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005163 bool skip = false;
5164
5165 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005166 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005167 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005168 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005169 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5170 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5171 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5172 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005173 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005174
5175 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005176 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005177 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5178 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5179 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5180 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5181 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5182 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5183 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5184 }
5185 }
5186
sourav parmarf4a78252020-04-10 13:04:21 -07005187 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5188 skip |=
5189 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5190 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5191 }
5192 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5193 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5194 skip |=
5195 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5196 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5197 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5198 }
5199 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5200 if (pCreateInfos[i].basePipelineIndex != -1) {
5201 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5202 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5203 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5204 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5205 "and pCreateInfos->basePipelineIndex is not -1.");
5206 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005207 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005208 skip |=
5209 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5210 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5211 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5212 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5213 "that element.");
5214 }
sourav parmarf4a78252020-04-10 13:04:21 -07005215 }
5216 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005217 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005218 skip |=
5219 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5220 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5221 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5222 "commands pCreateInfos parameter.");
5223 }
5224 } else {
5225 if (pCreateInfos[i].basePipelineIndex != -1) {
5226 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5227 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5228 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5229 }
5230 }
5231 }
5232 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5233 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5234 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5235 }
5236 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5237 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5238 "vkCreateRayTracingPipelinesNV: flags must not include "
5239 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5240 }
5241 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5242 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5243 "vkCreateRayTracingPipelinesNV: flags must not include "
5244 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5245 }
5246 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5247 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5248 "vkCreateRayTracingPipelinesNV: flags must not include "
5249 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5250 }
5251 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5252 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5253 "vkCreateRayTracingPipelinesNV: flags must not include "
5254 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5255 }
5256 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5257 skip |= LogError(
5258 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5259 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5260 }
5261 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5262 skip |= LogError(
5263 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5264 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5265 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005266 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5267 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5268 "vkCreateRayTracingPipelinesNV: flags must not include "
5269 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5270 }
5271 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5272 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5273 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5274 }
Peter Chen85366392019-05-14 15:20:11 -04005275 }
5276
5277 return skip;
5278}
5279
sourav parmarcd5fb182020-07-17 12:58:44 -07005280bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5281 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5282 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005283 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005284 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005285 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5286 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5287 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005288 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005289 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005290 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5291 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5292 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5293 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5294 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5295 }
5296 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5297 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5298 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5299 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5300 }
5301 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005302 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005303 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5304 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005305 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5306 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5307 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005308 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5309 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5310 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005311 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005312 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005313 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5314 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5315 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5316 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005317 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005318 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5319 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5320 }
5321 }
sourav parmarf4a78252020-04-10 13:04:21 -07005322 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005323 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5324 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005325 }
5326 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005327 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005328 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005329 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5330 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005331 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005332 }
5333 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5334 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5335 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005336 }
5337 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5338 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5339 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5340 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5341 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5342 skip |= LogError(
5343 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005344 "vkCreateRayTracingPipelinesKHR: If flags includes "
5345 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005346 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5347 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5348 "must not be VK_SHADER_UNUSED_KHR");
5349 }
5350 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5351 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5352 skip |= LogError(
5353 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005354 "vkCreateRayTracingPipelinesKHR: If flags includes "
5355 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005356 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5357 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5358 "element must not be VK_SHADER_UNUSED_KHR");
5359 }
5360 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005361 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5362 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5363 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5364 skip |= LogError(
5365 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5366 "vkCreateRayTracingPipelinesKHR: If "
5367 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5368 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5369 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5370 }
5371 }
sourav parmarf4a78252020-04-10 13:04:21 -07005372 }
5373 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5374 if (pCreateInfos[i].basePipelineIndex != -1) {
5375 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5376 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005377 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005378 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5379 "and pCreateInfos->basePipelineIndex is not -1.");
5380 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005381 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005382 skip |=
5383 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5384 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5385 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5386 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5387 "element.");
5388 }
sourav parmarf4a78252020-04-10 13:04:21 -07005389 }
5390 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005391 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005392 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005393 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005394 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5395 "commands pCreateInfos parameter %d.",
5396 pCreateInfos[i].basePipelineIndex, createInfoCount);
5397 }
5398 } else {
5399 if (pCreateInfos[i].basePipelineIndex != -1) {
5400 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005401 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005402 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5403 }
5404 }
5405 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005406 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5407 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5408 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5409 "vkCreateRayTracingPipelinesKHR: If flags includes "
5410 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5411 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005412 }
5413 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5414 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5415 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5416 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5417 "pLibraryInfo and pLibraryInterface must be NULL.");
5418 }
5419 if (pCreateInfos[i].pLibraryInfo) {
5420 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5421 if (pCreateInfos[i].stageCount == 0) {
5422 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5423 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5424 "stageCount must not be 0.");
5425 }
5426 if (pCreateInfos[i].groupCount == 0) {
5427 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5428 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5429 "groupCount must not be 0.");
5430 }
5431 } else {
5432 if (pCreateInfos[i].pLibraryInterface == NULL) {
5433 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5434 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5435 "is greater than 0, its "
5436 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005437 }
5438 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005439 }
5440 if (pCreateInfos[i].pLibraryInterface) {
5441 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5442 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5443 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5444 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5445 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5446 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005447 }
5448 if (deferredOperation != VK_NULL_HANDLE) {
5449 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5450 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5451 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5452 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005453 }
5454 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005455 }
5456
5457 return skip;
5458}
5459
Mike Schuchardt21638df2019-03-16 10:52:02 -07005460#ifdef VK_USE_PLATFORM_WIN32_KHR
5461bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5462 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005463 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005464 bool skip = false;
5465 if (!device_extensions.vk_khr_swapchain)
5466 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005467 if (!device_extensions.vk_khr_get_surface_capabilities2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005468 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5469 if (!device_extensions.vk_khr_surface)
5470 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005471 if (!device_extensions.vk_khr_get_physical_device_properties2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005472 skip |=
5473 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5474 if (!device_extensions.vk_ext_full_screen_exclusive)
5475 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5476 skip |= validate_struct_type(
5477 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5478 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5479 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5480 if (pSurfaceInfo != NULL) {
5481 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5482 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5483 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5484
5485 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5486 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5487 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5488 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005489 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5490 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005491
5492 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5493 }
5494 return skip;
5495}
5496#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005497
5498bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5499 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005500 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005501 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5502 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005503 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005504 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5505 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5506 }
5507 return skip;
5508}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005509
5510bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005511 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005512 bool skip = false;
5513
5514 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005515 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5516 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005517 }
5518
5519 return skip;
5520}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005521
5522bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005523 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005524 bool skip = false;
5525
5526 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005527 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5528 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005529 }
5530
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005531 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005532 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005533 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5534 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005535 }
5536
5537 return skip;
5538}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005539
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005540bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5541 uint32_t bindingCount, const VkBuffer *pBuffers,
5542 const VkDeviceSize *pOffsets) const {
5543 bool skip = false;
5544 if (firstBinding > device_limits.maxVertexInputBindings) {
5545 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5546 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5547 device_limits.maxVertexInputBindings);
5548 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5549 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5550 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5551 "maxVertexInputBindings (%u)",
5552 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5553 }
5554
Jeff Bolz165818a2020-05-08 11:19:03 -05005555 for (uint32_t i = 0; i < bindingCount; ++i) {
5556 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005557 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005558 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5559 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5560 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5561 } else {
5562 if (pOffsets[i] != 0) {
5563 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5564 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5565 }
5566 }
5567 }
5568 }
5569
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005570 return skip;
5571}
5572
Mark Lobodzinski84988402019-09-11 15:27:30 -06005573bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005574 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005575 bool skip = false;
5576 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005577 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5578 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005579 }
5580 return skip;
5581}
5582
5583bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005584 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005585 bool skip = false;
5586 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005587 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5588 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005589 }
5590 return skip;
5591}
Petr Kraus3d720392019-11-13 02:52:39 +01005592
5593bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5594 VkSemaphore semaphore, VkFence fence,
5595 uint32_t *pImageIndex) const {
5596 bool skip = false;
5597
5598 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005599 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5600 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005601 }
5602
5603 return skip;
5604}
5605
5606bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5607 uint32_t *pImageIndex) const {
5608 bool skip = false;
5609
5610 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005611 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5612 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005613 }
5614
5615 return skip;
5616}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005617
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005618bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5619 uint32_t firstBinding, uint32_t bindingCount,
5620 const VkBuffer *pBuffers,
5621 const VkDeviceSize *pOffsets,
5622 const VkDeviceSize *pSizes) const {
5623 bool skip = false;
5624
5625 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5626 for (uint32_t i = 0; i < bindingCount; ++i) {
5627 if (pOffsets[i] & 3) {
5628 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5629 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5630 }
5631 }
5632
5633 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5634 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5635 "%s: The firstBinding(%" PRIu32
5636 ") index is greater than or equal to "
5637 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5638 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5639 }
5640
5641 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5642 skip |=
5643 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5644 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5645 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5646 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5647 }
5648
5649 for (uint32_t i = 0; i < bindingCount; ++i) {
5650 // pSizes is optional and may be nullptr.
5651 if (pSizes != nullptr) {
5652 if (pSizes[i] != VK_WHOLE_SIZE &&
5653 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5654 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5655 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5656 ") is not VK_WHOLE_SIZE and is greater than "
5657 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5658 cmd_name, i, pSizes[i]);
5659 }
5660 }
5661 }
5662
5663 return skip;
5664}
5665
5666bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5667 uint32_t firstCounterBuffer,
5668 uint32_t counterBufferCount,
5669 const VkBuffer *pCounterBuffers,
5670 const VkDeviceSize *pCounterBufferOffsets) const {
5671 bool skip = false;
5672
5673 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5674 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5675 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5676 "%s: The firstCounterBuffer(%" PRIu32
5677 ") index is greater than or equal to "
5678 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5679 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5680 }
5681
5682 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5683 skip |=
5684 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5685 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5686 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5687 cmd_name, firstCounterBuffer, counterBufferCount,
5688 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5689 }
5690
5691 return skip;
5692}
5693
5694bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5695 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5696 const VkBuffer *pCounterBuffers,
5697 const VkDeviceSize *pCounterBufferOffsets) const {
5698 bool skip = false;
5699
5700 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5701 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5702 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5703 "%s: The firstCounterBuffer(%" PRIu32
5704 ") index is greater than or equal to "
5705 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5706 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5707 }
5708
5709 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5710 skip |=
5711 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5712 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5713 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5714 cmd_name, firstCounterBuffer, counterBufferCount,
5715 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5716 }
5717
5718 return skip;
5719}
5720
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005721bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5722 uint32_t firstInstance, VkBuffer counterBuffer,
5723 VkDeviceSize counterBufferOffset,
5724 uint32_t counterOffset, uint32_t vertexStride) const {
5725 bool skip = false;
5726
5727 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005728 skip |= LogError(
5729 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005730 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5731 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5732 }
5733
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005734 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005735 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005736 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005737 }
5738
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005739 return skip;
5740}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005741
5742bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5743 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5744 const VkAllocationCallbacks *pAllocator,
5745 VkSamplerYcbcrConversion *pYcbcrConversion,
5746 const char *apiName) const {
5747 bool skip = false;
5748
5749 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005750 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005751 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005752 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005753 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5754 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005755 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005756 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005757 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005758
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005759#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005760 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005761 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005762#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005763 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005764#endif
5765
sfricke-samsung1a72f942020-07-25 12:09:18 -07005766 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005767
5768 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005769 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005770 const VkComponentMapping components = pCreateInfo->components;
5771 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5772 if (FormatIsXChromaSubsampled(format) == true) {
5773 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5774 skip |=
5775 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005776 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5777 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005778 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005779 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005780
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005781 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5782 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5783 skip |= LogError(
5784 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5785 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5786 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5787 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5788 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005789
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005790 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5791 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5792 skip |=
5793 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005794 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5795 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005796 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005797 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005798
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005799 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5800 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5801 skip |=
5802 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005803 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5804 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005805 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005806 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005807
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005808 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005809 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5810 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5811 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005812 skip |=
5813 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005814 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5815 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005816 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5817 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005818 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005819 }
5820
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005821 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5822 // Checks same VU multiple ways in order to give a more useful error message
5823 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5824 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5825 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5826 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5827 skip |= LogError(
5828 device, vuid,
5829 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5830 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5831 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5832 string_VkComponentSwizzle(components.b));
5833 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005834
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005835 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5836 // 4 channel format = no issue
5837 // 3 = no [a]
5838 // 2 = no [b,a]
5839 // 1 = no [g,b,a]
5840 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5841 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5842
5843 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5844 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5845 skip |= LogError(device, vuid,
5846 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5847 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5848 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5849 string_VkComponentSwizzle(components.b));
5850 } else if ((channels < 3) &&
5851 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5852 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5853 skip |= LogError(device, vuid,
5854 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5855 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5856 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5857 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5858 string_VkComponentSwizzle(components.b));
5859 } else if ((channels < 2) &&
5860 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5861 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5862 skip |= LogError(device, vuid,
5863 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5864 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5865 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5866 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5867 string_VkComponentSwizzle(components.b));
5868 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005869 }
5870 }
5871
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005872 return skip;
5873}
5874
5875bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5876 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5877 const VkAllocationCallbacks *pAllocator,
5878 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5879 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5880 "vkCreateSamplerYcbcrConversion");
5881}
5882
5883bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5884 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5885 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5886 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5887 "vkCreateSamplerYcbcrConversionKHR");
5888}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005889
5890bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5891 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5892 bool skip = false;
5893 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5894 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5895
5896 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005897 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5898 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5899 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5900 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5901 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005902 }
5903 return skip;
5904}
sourav parmara96ab1a2020-04-25 16:28:23 -07005905
5906bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005907 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005908 bool skip = false;
5909 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5910 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5911 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5912 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005913 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005914 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5915 skip |= LogError(
5916 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5917 "vkCopyAccelerationStructureToMemoryKHR: The "
5918 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5919 }
5920 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5921 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5922 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5923 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5924 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5925 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005926 return skip;
5927}
5928
5929bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5930 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5931 bool skip = false;
5932 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5933 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5934 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5935 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5936 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005937 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5938 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005939 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07005940 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005941 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005942 return skip;
5943}
5944
5945bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5946 const char *api_name) const {
5947 bool skip = false;
5948 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5949 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5950 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5951 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5952 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5953 api_name);
5954 }
5955 return skip;
5956}
5957
5958bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005959 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005960 bool skip = false;
5961 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005962 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005963 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005964 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005965 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5966 "vkCopyAccelerationStructureKHR: The "
5967 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005968 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005969 return skip;
5970}
5971
5972bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5973 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5974 bool skip = false;
5975 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5976 return skip;
5977}
5978
5979bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005980 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005981 bool skip = false;
5982 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005983 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005984 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5985 }
5986 return skip;
5987}
5988
5989bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005990 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005991 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005992 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005993 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005994 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5995 skip |= LogError(
5996 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5997 "vkCopyMemoryToAccelerationStructureKHR: The "
5998 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005999 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006000 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6001 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006002 return skip;
6003}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006004
sourav parmara96ab1a2020-04-25 16:28:23 -07006005bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6006 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6007 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006008 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006009 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6010 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006011 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006012 pInfo->src.deviceAddress);
6013 }
sourav parmar83c31b12020-05-06 12:30:54 -07006014 return skip;
6015}
6016bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6017 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6018 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6019 bool skip = false;
6020 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6021 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6022 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6023 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6024 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6025 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6026 }
6027 return skip;
6028}
6029bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6030 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6031 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6032 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006033 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006034 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6035 skip |= LogError(
6036 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6037 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6038 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6039 }
sourav parmar83c31b12020-05-06 12:30:54 -07006040 if (dataSize < accelerationStructureCount * stride) {
6041 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6042 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
6043 "accelerationStructureCount (%d) *stride(%zu).",
6044 dataSize, accelerationStructureCount, stride);
6045 }
6046 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6047 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6048 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6049 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6050 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6051 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6052 }
6053 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6054 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6055 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6056 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6057 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6058 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6059 stride);
6060 }
6061 }
6062 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6063 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6064 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6065 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6066 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6067 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6068 stride);
6069 }
6070 }
sourav parmar83c31b12020-05-06 12:30:54 -07006071 return skip;
6072}
6073bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6074 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6075 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006076 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006077 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6078 skip |= LogError(
6079 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6080 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6081 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006082 }
6083 return skip;
6084}
6085
6086bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006087 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6088 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6089 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6090 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006091 uint32_t width, uint32_t height, uint32_t depth) const {
6092 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006093 // RayGen
6094 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6095 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6096 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006097 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006098 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6099 0) {
6100 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6101 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6102 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6103 }
6104 // Callable
6105 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6106 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6107 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6108 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006109 }
6110 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6111 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6112 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006113 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6114 }
6115 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6116 0) {
6117 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6118 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6119 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006120 }
6121 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006122 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6123 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6124 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6125 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006126 }
6127 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6128 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006129 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6130 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006131 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006132 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6133 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6134 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6135 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6136 }
sourav parmar83c31b12020-05-06 12:30:54 -07006137 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006138 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6139 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6140 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6141 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006142 }
6143 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6144 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6145 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006146 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6147 }
6148 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6149 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6150 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6151 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6152 }
6153 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6154 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6155 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6156 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6157 }
6158 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6159 skip |=
6160 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6161 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6162 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006163 }
6164
sourav parmarcd5fb182020-07-17 12:58:44 -07006165 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6166 skip |=
6167 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6168 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6169 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6170 }
6171
6172 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6173 skip |=
6174 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6175 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6176 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006177 }
6178 return skip;
6179}
6180
sourav parmarcd5fb182020-07-17 12:58:44 -07006181bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6182 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6183 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6184 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006185 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006186 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006187 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6188 skip |= LogError(
6189 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6190 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6191 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006192 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006193 // RayGen
6194 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6195 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6196 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006197 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006198 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6199 0) {
6200 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6201 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6202 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6203 }
6204 // Callabe
6205 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6206 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6207 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6208 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006209 }
6210 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6211 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006212 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6213 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6214 }
6215 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6216 0) {
6217 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6218 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6219 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006220 }
6221 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006222 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6223 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6224 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6225 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006226 }
6227 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6228 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006229 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6230 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006231 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006232 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6233 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6234 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6235 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6236 }
sourav parmar83c31b12020-05-06 12:30:54 -07006237 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006238 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6239 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6240 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6241 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006242 }
6243 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6244 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006245 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6246 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6247 }
6248 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6249 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6250 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6251 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006252 }
6253
sourav parmarcd5fb182020-07-17 12:58:44 -07006254 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6255 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6256 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006257 }
6258 return skip;
6259}
6260bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6261 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6262 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6263 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6264 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6265 uint32_t width, uint32_t height, uint32_t depth) const {
6266 bool skip = false;
6267 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6268 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6269 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6270 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6271 }
6272 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6273 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6274 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6275 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6276 }
6277 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6278 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6279 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6280 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6281 }
6282
6283 // hitShader
6284 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6285 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6286 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6287 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6288 }
6289 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6290 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6291 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6292 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6293 }
6294 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6295 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6296 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6297 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6298 }
6299
6300 // missShader
6301 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6302 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6303 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6304 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6305 }
6306 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6307 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6308 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6309 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6310 }
6311 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6312 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6313 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6314 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6315 }
6316
6317 // raygenShader
6318 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6319 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6320 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006321 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6322 }
6323 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6324 skip |=
6325 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6326 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6327 }
6328 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6329 skip |=
6330 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6331 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6332 }
6333 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6334 skip |=
6335 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6336 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006337 }
6338 return skip;
6339}
6340
sourav parmar83c31b12020-05-06 12:30:54 -07006341bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006342 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6343 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006344 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006345 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6346 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006347 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6348 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006349 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006350 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6351 }
6352 return skip;
6353}
6354
Piers Daniell39842ee2020-07-10 16:42:33 -06006355bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6356 const VkViewport *pViewports) const {
6357 bool skip = false;
6358
6359 if (!physical_device_features.multiViewport) {
6360 if (viewportCount != 1) {
6361 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6362 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6363 ") is not 1.",
6364 viewportCount);
6365 }
6366 } else { // multiViewport enabled
6367 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6368 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6369 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6370 ") must "
6371 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6372 viewportCount, device_limits.maxViewports);
6373 }
6374 }
6375
6376 if (pViewports) {
6377 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6378 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6379 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6380 skip |= manual_PreCallValidateViewport(
6381 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6382 }
6383 }
6384
6385 return skip;
6386}
6387
6388bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6389 const VkRect2D *pScissors) const {
6390 bool skip = false;
6391
6392 if (!physical_device_features.multiViewport) {
6393 if (scissorCount != 1) {
6394 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6395 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6396 ") must "
6397 "be 1 when the multiViewport feature is disabled.",
6398 scissorCount);
6399 }
6400 } else { // multiViewport enabled
6401 if (scissorCount == 0) {
6402 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6403 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6404 ") must "
6405 "be great than zero.",
6406 scissorCount);
6407 } else if (scissorCount > device_limits.maxViewports) {
6408 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6409 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6410 ") must "
6411 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6412 scissorCount, device_limits.maxViewports);
6413 }
6414 }
6415
6416 if (pScissors) {
6417 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6418 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6419
6420 if (scissor.offset.x < 0) {
6421 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6422 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6423 scissor.offset.x);
6424 }
6425
6426 if (scissor.offset.y < 0) {
6427 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6428 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6429 scissor.offset.y);
6430 }
6431
6432 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6433 if (x_sum > INT32_MAX) {
6434 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6435 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6436 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6437 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6438 }
6439
6440 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6441 if (y_sum > INT32_MAX) {
6442 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6443 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6444 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6445 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6446 }
6447 }
6448 }
6449
6450 return skip;
6451}
6452
6453bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6454 uint32_t bindingCount, const VkBuffer *pBuffers,
6455 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6456 const VkDeviceSize *pStrides) const {
6457 bool skip = false;
6458 if (firstBinding >= device_limits.maxVertexInputBindings) {
6459 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6460 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6461 firstBinding, device_limits.maxVertexInputBindings);
6462 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6463 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6464 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6465 "maxVertexInputBindings (%u)",
6466 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6467 }
6468
6469 for (uint32_t i = 0; i < bindingCount; ++i) {
6470 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006471 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006472 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6473 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6474 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6475 } else {
6476 if (pOffsets[i] != 0) {
6477 skip |=
6478 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6479 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6480 }
6481 }
6482 }
6483 if (pStrides) {
6484 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6485 skip |=
6486 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006487 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i,
Piers Daniell39842ee2020-07-10 16:42:33 -06006488 pStrides[i], device_limits.maxVertexInputBindingStride);
6489 }
6490 }
6491 }
6492
6493 return skip;
6494}
sourav parmarcd5fb182020-07-17 12:58:44 -07006495
6496bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6497 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6498 bool skip = false;
6499 for (uint32_t i = 0; i < infoCount; ++i) {
6500 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6501 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6502 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6503 }
6504 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6505 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6506 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6507 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6508 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6509 api_name);
6510 }
6511 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6512 skip |=
6513 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6514 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6515 }
6516 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6517 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6518 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6519 }
6520 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6521 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6522 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6523 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6524 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6525 api_name);
6526 }
6527 if (pInfos[i].pGeometries) {
6528 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6529 skip |= validate_ranged_enum(
6530 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6531 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6532 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6533 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006534 skip |= validate_struct_type(
6535 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6536 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6537 &(pInfos[i].pGeometries[j].geometry.triangles),
6538 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6539 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6540 skip |= validate_struct_pnext(
6541 api_name,
6542 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6543 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6544 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6545 skip |=
6546 validate_ranged_enum(api_name,
6547 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6548 ParameterName::IndexVector{i, j}),
6549 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6550 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6551 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6552 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6553 &pInfos[i].pGeometries[j].geometry.triangles,
6554 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6555 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6556 skip |= validate_ranged_enum(
6557 api_name,
6558 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6559 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6560 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6561
6562 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6563 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6564 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6565 }
6566 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6567 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6568 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6569 skip |=
6570 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6571 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6572 api_name);
6573 }
6574 }
6575 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6576 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6577 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6578 &pInfos[i].pGeometries[j].geometry.instances,
6579 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6580 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6581 skip |= validate_struct_type(
6582 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6583 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6584 &(pInfos[i].pGeometries[j].geometry.instances),
6585 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6586 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6587 skip |= validate_struct_pnext(
6588 api_name,
6589 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6590 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6591 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6592
6593 skip |= validate_bool32(api_name,
6594 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6595 ParameterName::IndexVector{i, j}),
6596 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6597 }
6598 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6599 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6600 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6601 &pInfos[i].pGeometries[j].geometry.aabbs,
6602 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6603 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6604 skip |= validate_struct_type(
6605 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6606 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6607 &(pInfos[i].pGeometries[j].geometry.aabbs),
6608 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6609 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6610 skip |= validate_struct_pnext(
6611 api_name,
6612 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6613 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6614 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6615 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6616 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6617 "(%s):stride must be less than or equal to 2^32-1", api_name);
6618 }
6619 }
6620 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6621 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6622 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6623 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6624 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6625 api_name);
6626 }
6627 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6628 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6629 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6630 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6631 "of elements of"
6632 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6633 api_name);
6634 }
6635 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6636 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6637 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6638 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6639 api_name);
6640 }
6641 }
6642 }
6643 }
6644 if (pInfos[i].ppGeometries != NULL) {
6645 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6646 skip |= validate_ranged_enum(
6647 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6648 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6649 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6650 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006651 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6652 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6653 &pInfos[i].ppGeometries[j]->geometry.triangles,
6654 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6655 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6656 skip |= validate_struct_type(
6657 api_name,
6658 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6659 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6660 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6661 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6662 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6663 skip |= validate_struct_pnext(
6664 api_name,
6665 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6666 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6667 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6668 skip |= validate_ranged_enum(api_name,
6669 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6670 ParameterName::IndexVector{i, j}),
6671 "VkFormat", AllVkFormatEnums,
6672 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6673 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6674 skip |= validate_ranged_enum(api_name,
6675 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6676 ParameterName::IndexVector{i, j}),
6677 "VkIndexType", AllVkIndexTypeEnums,
6678 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6679 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6680 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6681 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6682 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6683 }
6684 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6685 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6686 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6687 skip |=
6688 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6689 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6690 api_name);
6691 }
6692 }
6693 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6694 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6695 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6696 &pInfos[i].ppGeometries[j]->geometry.instances,
6697 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6698 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6699 skip |= validate_struct_type(
6700 api_name,
6701 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6702 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6703 &(pInfos[i].ppGeometries[j]->geometry.instances),
6704 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6705 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6706 skip |= validate_struct_pnext(
6707 api_name,
6708 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6709 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6710 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6711 skip |= validate_bool32(api_name,
6712 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6713 ParameterName::IndexVector{i, j}),
6714 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6715 }
6716 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6717 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6718 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6719 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6720 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6721 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6722 skip |= validate_struct_type(
6723 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6724 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6725 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6726 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6727 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6728 skip |= validate_struct_pnext(
6729 api_name,
6730 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6731 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6732 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6733 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6734 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6735 "(%s):stride must be less than or equal to 2^32-1", api_name);
6736 }
6737 }
6738 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6739 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6740 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6741 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6742 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6743 api_name);
6744 }
6745 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6746 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6747 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6748 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6749 "of elements of"
6750 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6751 api_name);
6752 }
6753 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6754 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6755 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6756 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6757 api_name);
6758 }
6759 }
6760 }
6761 }
6762 }
6763 return skip;
6764}
6765bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6766 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6767 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6768 bool skip = false;
6769 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6770 for (uint32_t i = 0; i < infoCount; ++i) {
6771 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6772 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6773 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6774 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6775 "scratchData.deviceAddress member must be a multiple of "
6776 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6777 }
6778 for (uint32_t k = 0; k < infoCount; ++k) {
6779 if (i == k) continue;
6780 bool found = false;
6781 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6782 skip |= LogError(
6783 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6784 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6785 "not be "
6786 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6787 i, k);
6788 found = true;
6789 }
6790 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6791 skip |= LogError(
6792 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6793 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6794 "not be "
6795 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6796 i, k);
6797 found = true;
6798 }
6799 if (found) break;
6800 }
6801 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6802 if (pInfos[i].pGeometries) {
6803 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6804 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6805 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6806 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6807 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6808 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6809 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6810 }
6811 } else {
6812 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6813 skip |=
6814 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6815 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6816 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6817 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6818 }
6819 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006820 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006821 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6822 skip |= LogError(
6823 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6824 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6825 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6826 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006827 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6828 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006829 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6830 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6831 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6832 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6833 }
6834 }
6835 } else if (pInfos[i].ppGeometries) {
6836 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6837 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6838 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6839 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6840 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6841 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6842 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6843 }
6844 } else {
6845 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6846 skip |=
6847 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6848 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6849 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6850 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6851 }
6852 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006853 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006854 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6855 skip |= LogError(
6856 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6857 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6858 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6859 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006860 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6861 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006862 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6863 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6864 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6865 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6866 }
6867 }
6868 }
6869 }
6870 }
6871 return skip;
6872}
6873
6874bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6875 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6876 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6877 const uint32_t *const *ppMaxPrimitiveCounts) const {
6878 bool skip = false;
6879 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6880 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006881 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006882 if (!ray_tracing_acceleration_structure_features ||
6883 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6884 skip |= LogError(
6885 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6886 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6887 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6888 }
6889 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006890 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6891 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6892 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6893 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6894 "scratchData.deviceAddress member must be a multiple of "
6895 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6896 }
6897 for (uint32_t k = 0; k < infoCount; ++k) {
6898 if (i == k) continue;
6899 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6900 skip |=
6901 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6902 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6903 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6904 "any other element [%d) of pInfos.",
6905 i, k);
6906 break;
6907 }
6908 }
6909 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6910 if (pInfos[i].pGeometries) {
6911 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6912 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6913 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6914 skip |= LogError(
6915 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6916 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6917 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6918 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6919 }
6920 } else {
6921 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6922 skip |= LogError(
6923 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6924 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6925 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6926 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6927 }
6928 }
6929 }
6930 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6931 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6932 skip |= LogError(
6933 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6934 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6935 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6936 }
6937 }
6938 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6939 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6940 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6941 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6942 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6943 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6944 }
6945 }
6946 } else if (pInfos[i].ppGeometries) {
6947 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6948 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6949 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6950 skip |= LogError(
6951 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6952 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6953 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6954 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6955 }
6956 } else {
6957 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6958 skip |= LogError(
6959 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6960 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6961 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6962 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6963 }
6964 }
6965 }
6966 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6967 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6968 skip |= LogError(
6969 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6970 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6971 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6972 }
6973 }
6974 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6975 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6976 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6977 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6978 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6979 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6980 }
6981 }
6982 }
6983 }
6984 }
6985 return skip;
6986}
6987
6988bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6989 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6990 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6991 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6992 bool skip = false;
6993 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6994 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006995 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006996 if (!ray_tracing_acceleration_structure_features ||
6997 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6998 skip |=
6999 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7000 "vkBuildAccelerationStructuresKHR: The "
7001 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7002 }
7003 for (uint32_t i = 0; i < infoCount; ++i) {
7004 for (uint32_t j = 0; j < infoCount; ++j) {
7005 if (i == j) continue;
7006 bool found = false;
7007 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7008 skip |= LogError(
7009 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7010 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
7011 "not be "
7012 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7013 i, j);
7014 found = true;
7015 }
7016 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7017 skip |= LogError(
7018 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7019 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
7020 "not be "
7021 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7022 i, j);
7023 found = true;
7024 }
7025 if (found) break;
7026 }
7027 }
7028 return skip;
7029}
7030
7031bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7032 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7033 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7034 bool skip = false;
7035 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7036 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007037 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7038 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007039 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7040 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7041 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7042 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7043 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7044 }
7045 return skip;
7046}
sfricke-samsungecafb192021-01-17 08:21:14 -08007047
7048bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7049 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7050 const VkAllocationCallbacks *pAllocator,
7051 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7052 bool skip = false;
7053 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7054 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7055 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7056 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7057 }
7058 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007059}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007060
7061bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7062 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7063 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7064 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7065 bool skip = false;
7066 const auto *vertex_input_dynamic_state_features =
7067 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7068 const auto *vertex_attribute_divisor_features =
7069 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7070
7071 // VUID-vkCmdSetVertexInputEXT-None-04790
7072 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7073 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7074 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7075 }
7076
7077 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7078 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7079 skip |=
7080 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7081 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7082 }
7083
7084 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7085 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7086 skip |= LogError(
7087 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7088 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7089 }
7090
7091 // VUID-vkCmdSetVertexInputEXT-binding-04793
7092 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7093 bool binding_found = false;
7094 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7095 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7096 binding_found = true;
7097 break;
7098 }
7099 }
7100 if (!binding_found) {
7101 skip |=
7102 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7103 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
7104 }
7105 }
7106
7107 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7108 if (vertexBindingDescriptionCount > 1) {
7109 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7110 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7111 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7112 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7113 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
7114 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
7115 }
7116 }
7117 }
7118 }
7119
7120 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7121 if (vertexAttributeDescriptionCount > 1) {
7122 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7123 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7124 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7125 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7126 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
7127 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
7128 }
7129 }
7130 }
7131 }
7132
7133 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7134 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7135 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
7136 skip |= LogError(
7137 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7138 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
7139 }
7140
7141 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7142 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
7143 skip |= LogError(
7144 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7145 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
7146 binding);
7147 }
7148
7149 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7150 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7151 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7152 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7153 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7154 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7155 binding);
7156 }
7157
7158 if (pVertexBindingDescriptions[binding].divisor > 1) {
7159 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7160 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7161 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7162 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7163 "vertexAttributeInstanceRateDivisor is not enabled",
7164 binding);
7165 } else {
7166 // VUID-VkVertexInputBindingDescription2EXT-divisor-04800
7167 if (pVertexBindingDescriptions[binding].divisor >
7168 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7169 skip |= LogError(
7170 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04800",
7171 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7172 binding);
7173 }
7174
7175 // VUID-VkVertexInputBindingDescription2EXT-divisor-04801
7176 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7177 skip |=
7178 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04801",
7179 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7180 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7181 binding);
7182 }
7183 }
7184 }
7185 }
7186
7187 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7188 // VUID-VkVertexInputAttributeDescription2EXT-location-04802
7189 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7190 skip |= LogError(
7191 device, "VUID-VkVertexInputAttributeDescription2EXT-location-04802",
7192 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7193 attribute);
7194 }
7195
7196 // VUID-VkVertexInputAttributeDescription2EXT-binding-04803
7197 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7198 skip |= LogError(
7199 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-04803",
7200 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7201 attribute);
7202 }
7203
7204 // VUID-VkVertexInputAttributeDescription2EXT-offset-04804
7205 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7206 skip |= LogError(
7207 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-04804",
7208 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7209 attribute);
7210 }
7211
7212 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7213 VkFormatProperties properties;
7214 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7215 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7216 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7217 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7218 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7219 attribute);
7220 }
7221 }
7222
7223 return skip;
7224}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007225
7226bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7227 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7228 const void *pValues) const {
7229 bool skip = false;
7230 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7231 // Check that offset + size don't exceed the max.
7232 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7233 if (offset >= max_push_constants_size) {
7234 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7235 "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset,
7236 max_push_constants_size);
7237 }
7238 if (size > max_push_constants_size - offset) {
7239 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
7240 "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.",
7241 offset, size, max_push_constants_size);
7242 }
7243
7244 // size needs to be non-zero and a multiple of 4.
7245 if (size & 0x3) {
7246 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.",
7247 size);
7248 }
7249
7250 // offset needs to be a multiple of 4.
7251 if ((offset & 0x3) != 0) {
7252 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007253 "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007254 }
7255 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007256}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007257
7258bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7259 uint32_t srcCacheCount,
7260 const VkPipelineCache *pSrcCaches) const {
7261 bool skip = false;
7262 if (pSrcCaches) {
7263 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7264 if (pSrcCaches[index0] == dstCache) {
7265 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7266 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7267 report_data->FormatHandle(dstCache).c_str());
7268 break;
7269 }
7270 }
7271 }
7272 return skip;
7273}