blob: 68872b1b63223e74bc05dcf5781ed4d93139f729 [file] [log] [blame]
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070028static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060029
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070036read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); }
37write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); }
38
Jeremy Gebbencbf22862021-03-03 12:01:22 -070039static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070040static ReadWriteLock secondary_cb_map_mutex;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -070041static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); }
42static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070044bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050045 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060046 bool skip = false;
47
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070048 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060049
50 if (result == VK_STRING_ERROR_NONE) {
51 return skip;
52 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070053 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070054 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060055 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070056 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
57 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060058 }
59 return skip;
60}
61
Jeff Bolz46c0ea02019-10-09 13:06:29 -050062bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060063 bool skip = false;
64 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
65 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080066 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
67 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070068 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
69 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
70 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060071 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070072 skip |= LogWarning(instance, kVUIDUndefined,
73 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
74 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
75 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060076 }
77 }
78 return skip;
79}
80
Jeff Bolz46c0ea02019-10-09 13:06:29 -050081bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060082 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060083 // Create and use a local instance extension object, as an actual instance has not been created yet
84 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
85 InstanceExtensions local_instance_extensions;
86 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
87
John Zulauf620755c2018-04-16 11:00:43 -060088 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060089 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
90 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060091 }
92
93 return skip;
94}
95
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060096bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -070097 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060098 // Struct is legal IF it's supported
99 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
100 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
101 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
102 if (enum_iter != dev_exts_enumerated->second.cend()) {
103 return true;
104 }
105 }
106 return false;
107}
108
Tony-LunarG866843d2020-05-13 11:22:42 -0600109bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
110 const VkValidationFeaturesEXT *validation_features) const {
111 bool skip = false;
112 bool debug_printf = false;
113 bool gpu_assisted = false;
114 bool reserve_slot = false;
115 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
116 switch (validation_features->pEnabledValidationFeatures[i]) {
117 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
118 gpu_assisted = true;
119 break;
120
121 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
122 debug_printf = true;
123 break;
124
125 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
126 reserve_slot = true;
127 break;
128
129 default:
130 break;
131 }
132 }
133 if (reserve_slot && !gpu_assisted) {
134 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
135 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
136 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
137 }
138 if (gpu_assisted && debug_printf) {
139 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
140 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
141 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
142 }
143
144 return skip;
145}
146
John Zulauf620755c2018-04-16 11:00:43 -0600147template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700148ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
149 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600150 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700151 ExtEnabled state =
152 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600153 return state;
154}
155
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700156bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500157 const VkAllocationCallbacks *pAllocator,
158 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 bool skip = false;
160 // Note: From the spec--
161 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
162 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
163 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700164 ? pCreateInfo->pApplicationInfo->apiVersion
165 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700166 skip |= validate_api_version(local_api_version, api_version);
167 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700168 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600169 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
170
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700171 return skip;
172}
173
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700174void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700175 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
176 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700177 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
178 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700179 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700180 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700181}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600182
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700183void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
184 // Assume phys_devices is valid
185 assert(phys_devices);
186 for (int i = 0; i < count; ++i) {
187 const auto &phys_device = phys_devices[i];
188 if (0 == physical_device_properties_map.count(phys_device)) {
189 auto phys_dev_props = new VkPhysicalDeviceProperties;
190 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
191 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600192
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700193 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
194 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700195 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700196 std::vector<VkExtensionProperties> ext_props{};
197 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
198 ext_props.resize(ext_count);
199 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
200 for (uint32_t j = 0; j < ext_count; j++) {
201 dev_exts_enumerated.insert(ext_props[j].extensionName);
202 }
203 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600204 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700205 }
206}
207
208void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
209 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
210 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
211 return;
212 }
213
214 if (pPhysicalDeviceCount && pPhysicalDevices) {
215 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
216 }
217}
218
219void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
220 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
221 VkResult result) {
222 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
223 return;
224 }
225
226 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
227 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
228 const auto &group = pPhysicalDeviceGroupProperties[i];
229 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
230 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600231 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700232}
233
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600234void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
235 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
236 delete (it->second);
237 it = physical_device_properties_map.erase(it);
238 }
239};
240
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700241void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700242 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700243 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700244 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700245 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
246 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700247
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248 // Parmeter validation also uses extension data
249 stateless_validation->device_extensions = this->device_extensions;
250
251 VkPhysicalDeviceProperties device_properties = {};
252 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600253 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700254 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
255
256 if (device_extensions.vk_nv_shading_rate_image) {
257 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700258 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
259 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600260 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700261 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
262 }
263
264 if (device_extensions.vk_nv_mesh_shader) {
265 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700266 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
267 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600268 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700269 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
270 }
271
Jason Macnak5c954952019-07-09 15:46:12 -0700272 if (device_extensions.vk_nv_ray_tracing) {
273 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700274 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
275 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700276 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500277 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
278 }
279
sourav parmarcd5fb182020-07-17 12:58:44 -0700280 if (device_extensions.vk_khr_ray_tracing_pipeline) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500281 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700282 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
283 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500284 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
285 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700286 }
287
sourav parmarcd5fb182020-07-17 12:58:44 -0700288 if (device_extensions.vk_khr_acceleration_structure) {
289 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700290 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
291 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700292 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
293 phys_dev_ext_props.acc_structure_props = acc_structure_props;
294 }
295
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700296 if (device_extensions.vk_ext_transform_feedback) {
297 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700298 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
299 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700300 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
301 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
302 }
303
Piers Daniellcb6d8032021-04-19 18:51:26 -0600304 if (device_extensions.vk_ext_vertex_attribute_divisor) {
305 // Get the needed vertex attribute divisor limits
306 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
307 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
308 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
309 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
310 }
311
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800312 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
313
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700314 // Save app-enabled features in this device's validation object
315 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700316 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200317 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
318 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
319 if (features2) {
320 tmp_features2_state.features = features2->features;
321 } else if (pCreateInfo->pEnabledFeatures) {
322 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700323 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200324 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700325 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200326 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700327 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200328 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700329}
330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700331bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500332 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600333 bool skip = false;
334
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200335 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
336 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
337 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600338 }
339
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700340 // If this device supports VK_KHR_portability_subset, it must be enabled
341 const std::string portability_extension_name("VK_KHR_portability_subset");
342 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
343 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
344 bool portability_requested = false;
345
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200346 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
347 skip |=
348 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
349 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
350 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
351 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700352 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
353 portability_requested = true;
354 }
355 }
356
357 if (portability_supported && !portability_requested) {
358 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
359 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
360 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600361 }
362
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200363 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700364 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
365 bool negative_viewport =
366 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200367 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700368 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
369 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
370 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200371 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600372 }
373
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600374 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200375 bool khr_bda =
376 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
377 bool ext_bda =
378 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600379 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700380 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
381 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
382 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600383 }
384 }
385
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600386 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
387 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700388 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600389 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800390 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700391 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800392 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700393 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600394 }
395 }
396
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700397 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500398 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700399 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500400 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
401 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
402 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
403 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700404 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700405 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
406 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
407 skip |= LogError(
408 device,
409 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
410 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
411 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700412 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700413 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600414 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
415 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
416 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
417 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600418 }
419
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700420 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700421 if (vulkan_11_features) {
422 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
423 while (current) {
424 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
425 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
426 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
427 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
428 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
429 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700430 skip |= LogError(
431 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700432 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
433 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
434 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
435 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
436 break;
437 }
438 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
439 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800440
441 // Check features are enabled if matching extension is passed in as well
442 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
443 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
444 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
445 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
446 skip |= LogError(
447 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
448 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
449 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
450 }
451 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700452 }
453
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700454 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700455 if (vulkan_12_features) {
456 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
457 while (current) {
458 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
459 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
460 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
461 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
462 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
463 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
464 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
465 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
466 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
467 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
469 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
470 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700471 skip |= LogError(
472 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700473 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
474 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
475 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
476 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
477 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
478 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
479 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
480 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
481 break;
482 }
483 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
484 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700485 // Check features are enabled if matching extension is passed in as well
486 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
487 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
488 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
489 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
490 skip |= LogError(
491 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
492 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
493 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
494 }
495 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
496 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
497 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
498 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
499 "is not VK_TRUE.",
500 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
501 }
502 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
503 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
504 skip |= LogError(
505 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
506 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
507 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
508 }
509 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
510 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
511 skip |= LogError(
512 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
513 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
514 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
515 }
516 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
517 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
518 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
519 skip |=
520 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
521 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
522 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
523 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
524 }
525 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200526 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
527 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
528 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
529 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
530 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
531 }
532 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700533 }
534
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600535 // Validate pCreateInfo->pQueueCreateInfos
536 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600537
538 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700539 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
540 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600541 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700542 skip |=
543 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
544 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
545 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
546 "index value.",
547 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600548 }
549
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700550 if (queue_create_info.pQueuePriorities != nullptr) {
551 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
552 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600553 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700554 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
555 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
556 "] (=%f) is not between 0 and 1 (inclusive).",
557 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600558 }
559 }
560 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700561
562 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700563 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700564 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700565 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700566 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700567 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700568 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700569 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700570 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700571 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700572 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
573 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
574 "protectedMemory feature being set as well.");
575 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600576 }
577 }
578
sfricke-samsung30a57412020-05-15 21:14:54 -0700579 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700580 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700581 VkBool32 variable_pointers = VK_FALSE;
582 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700583 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700584 variable_pointers = vulkan_11_features->variablePointers;
585 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700586 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700587 variable_pointers = variable_pointers_features->variablePointers;
588 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700589 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700590 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700591 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
592 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
593 }
594
sfricke-samsungfd76c342020-05-29 23:13:43 -0700595 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700596 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700597 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700598 VkBool32 multiview_geometry_shader = VK_FALSE;
599 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700600 if (vulkan_11_features) {
601 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700602 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
603 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700604 } else if (multiview_features) {
605 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700606 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
607 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700608 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700609 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700610 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
611 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
612 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700613 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700614 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
615 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
616 }
617
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600618 return skip;
619}
620
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500621bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700622 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700623 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
624 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
625 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 }
627
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700628 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600629}
630
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700631bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500632 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100633 bool skip = false;
634
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600635 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700636 skip |=
637 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600638
639 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
640 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
641 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
642 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700643 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
644 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
645 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600646 }
647
648 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
649 // queueFamilyIndexCount uint32_t values
650 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700651 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
652 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
653 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
654 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600655 }
656 }
657
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700658 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
659 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
660 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
661 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
662 }
663
664 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
665 skip |=
666 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
667 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
668 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
669 }
670
671 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
672 skip |=
673 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
674 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
675 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
676 }
677
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600678 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
679 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
680 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
681 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700682 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
683 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
684 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600685 }
686 }
687
688 return skip;
689}
690
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700691bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500692 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600693 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600694
695 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800696 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700697 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600698 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
699 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
700 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
701 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700702 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
703 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
704 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600705 }
706
707 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
708 // queueFamilyIndexCount uint32_t values
709 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
711 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
712 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
713 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714 }
715 }
716
Dave Houlton413a6782018-05-22 13:01:54 -0600717 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600719 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700720 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600721 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700722 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600723
Dave Houlton413a6782018-05-22 13:01:54 -0600724 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700725 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600726 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700727 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600728
Dave Houlton130c0212018-01-29 13:39:56 -0700729 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700730 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
731 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700732 skip |= LogError(
733 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600734 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
735 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700736 }
737
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600738 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100739 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
740 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700741 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
742 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
743 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600744 }
745
746 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700747 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100748 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700749 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
750 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
751 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
752 ") are not equal.",
753 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100754 }
755
756 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700757 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
758 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
759 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
760 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100761 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600762 }
763
764 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700765 skip |= LogError(
766 device, "VUID-VkImageCreateInfo-imageType-00957",
767 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600768 }
769 }
770
Dave Houlton130c0212018-01-29 13:39:56 -0700771 // 3D image may have only 1 layer
772 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
774 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700775 }
776
Dave Houlton130c0212018-01-29 13:39:56 -0700777 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
778 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
779 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
780 // At least one of the legal attachment bits must be set
781 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700782 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
783 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700784 }
785 // No flags other than the legal attachment bits may be set
786 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
787 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700788 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
789 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700790 }
791 }
792
Jeff Bolzef40fec2018-09-01 22:04:34 -0500793 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700794 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500795 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700796 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700797 ? static_cast<uint32_t>(ceil(log2(max_dim)))
798 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
799 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600800 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700801 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
802 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
803 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600804 }
805
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700806 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700807 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
808 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
809 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600810 }
811
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700812 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700813 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
814 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
815 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100816 }
817
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700818 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700819 skip |= LogError(
820 device, "VUID-VkImageCreateInfo-flags-01924",
821 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
822 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
823 }
824
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600825 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
826 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700827 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
828 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700829 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
830 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
831 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600832 }
833
834 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700835 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600836 // Linear tiling is unsupported
837 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700838 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700839 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
840 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600841 }
842
843 // Sparse 1D image isn't valid
844 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700845 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
846 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600847 }
848
849 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700850 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700851 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
852 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
853 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600854 }
855
856 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700857 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700858 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
859 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
860 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600861 }
862
863 // Multi-sample 2D image when device doesn't support it
864 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700865 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600866 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700867 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
868 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
869 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700870 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600871 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700872 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
873 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
874 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700875 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600876 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700877 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
878 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
879 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700880 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600881 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700882 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
883 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
884 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600885 }
886 }
887 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500888
Jeff Bolz9af91c52018-09-01 21:53:57 -0500889 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
890 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700891 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
892 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
893 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500894 }
895 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700896 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
897 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
898 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500899 }
900 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700901 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
902 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
903 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500904 }
905 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500906
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700907 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600908 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700909 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
910 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
911 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500912 }
913
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700914 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700915 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
916 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800917 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
918 "depth/stencil format.",
919 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500920 }
921
Dave Houlton142c4cb2018-10-17 15:04:41 -0600922 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700923 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
924 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
925 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
926 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500927 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600928 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700929 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
930 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
931 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
932 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500933 }
934 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500935
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700936 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800937 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700938 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
939 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800940 "format (%s) must be a depth or depth/stencil format.",
941 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700942 }
943
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700944 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500945 if (image_stencil_struct != nullptr) {
946 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
947 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
948 // No flags other than the legal attachment bits may be set
949 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
950 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700951 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
952 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
953 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
954 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500955 }
956 }
957
sfricke-samsung61a57c02021-01-10 21:35:12 -0800958 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500959 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
960 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800961 skip |= LogError(
962 device, "VUID-VkImageCreateInfo-Format-02536",
963 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
964 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
965 "maxFramebufferWidth (%u)",
966 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500967 }
968
969 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800970 skip |= LogError(
971 device, "VUID-VkImageCreateInfo-format-02537",
972 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
973 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
974 "maxFramebufferHeight (%u)",
975 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500976 }
977 }
978
979 if (!physical_device_features.shaderStorageImageMultisample &&
980 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
981 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
982 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700983 LogError(device, "VUID-VkImageCreateInfo-format-02538",
984 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
985 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
986 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500987 }
988
989 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
990 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700991 skip |= LogError(
992 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500993 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
994 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
995 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
996 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
997 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700998 skip |= LogError(
999 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001000 "vkCreateImage(): Depth-stencil image in which usage does not include "
1001 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1002 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1003 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1004 }
1005
1006 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1007 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001008 skip |= LogError(
1009 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001010 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1011 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1012 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1013 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1014 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001015 skip |= LogError(
1016 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001017 "vkCreateImage(): Depth-stencil image in which usage does not include "
1018 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1019 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1020 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1021 }
1022 }
1023 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001024
1025 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1026 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1027 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1028 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1029 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1030 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001031
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001032 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001033 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001034 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1035 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001036 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1037 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1038 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1039 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1040 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1041 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1042 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001043 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001044 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1045 } else if (drm_format_mod_list != nullptr) {
1046 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1047 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1048 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001049 }
1050 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1051 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1052 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1053 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1054 "in the pNext chain");
1055 }
1056 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001057
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001058 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001059 bool image_create_maybe_linear = false;
1060 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1061 image_create_maybe_linear = true;
1062 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1063 image_create_maybe_linear = false;
1064 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1065 image_create_maybe_linear =
1066 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001067 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001068 }
1069
1070 // If multi-sample, validate type, usage, tiling and mip levels.
1071 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001072 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001073 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1074 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1075 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1076 }
1077
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001078 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001079 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1080 image_create_maybe_linear)) {
1081 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1082 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1083 }
1084
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001085 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1086 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1087 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1088 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1089 "imageType must be VK_IMAGE_TYPE_2D.");
1090 }
1091 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1092 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1093 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1094 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1095 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001096 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001097 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001098 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1099 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1100 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1101 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1102 }
1103 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1104 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1105 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1106 "imageType must be VK_IMAGE_TYPE_2D.");
1107 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001108 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001109 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1110 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1111 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1112 }
1113 if (pCreateInfo->mipLevels != 1) {
1114 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1115 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1116 pCreateInfo->mipLevels);
1117 }
1118 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001119
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001120 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001121 if (swapchain_create_info != nullptr) {
1122 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1123 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1124 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1125 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1126 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1127 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1128
1129 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1130 // also implicitly forces the check above that extent.depth is 1
1131 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1132 string_VkImageType(pCreateInfo->imageType));
1133 }
1134 if (pCreateInfo->mipLevels != 1) {
1135 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1136 pCreateInfo->mipLevels);
1137 }
1138 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1139 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1140 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1141 }
1142 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1143 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1144 base_message, string_VkImageTiling(pCreateInfo->tiling));
1145 }
1146 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1147 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1148 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1149 }
1150 const VkImageCreateFlags valid_flags =
1151 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001152 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001153 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001154 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001155 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001156 }
1157 }
1158 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001159
1160 // If Chroma subsampled format ( _420_ or _422_ )
1161 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1162 skip |=
1163 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1164 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1165 ") must be a multiple of 2.",
1166 string_VkFormat(image_format), pCreateInfo->extent.width);
1167 }
1168 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1169 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1170 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1171 ") must be a multiple of 2.",
1172 string_VkFormat(image_format), pCreateInfo->extent.height);
1173 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001174
1175 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1176 if (format_list_info) {
1177 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1178 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1179 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1180 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1181 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1182 viewFormatCount);
1183 }
1184 // Check if viewFormatCount is not zero that it is all compatible
1185 for (uint32_t i = 0; i < viewFormatCount; i++) {
1186 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1187 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1188 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1189 "VkImageCreateInfo::format (%s) are not compatible.",
1190 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1191 }
1192 }
1193 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001194 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001195
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001196 return skip;
1197}
1198
Jeff Bolz99e3f632020-03-24 22:59:22 -05001199bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1200 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1201 bool skip = false;
1202
1203 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001204 // Validate feature set if using CUBE_ARRAY
1205 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1206 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1207 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1208 "enabling the imageCubeArray feature.");
1209 }
1210
Jeff Bolz99e3f632020-03-24 22:59:22 -05001211 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1212 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1213 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001214 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001215 pCreateInfo->subresourceRange.layerCount);
1216 }
1217 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001218 skip |= LogError(
1219 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1220 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1221 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001222 }
1223 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001224
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001225 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001226 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1227 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1228 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1229 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1230 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1231 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1232 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1233 }
1234 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1235 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1236 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1237 "not an ASTC format.",
1238 string_VkFormat(pCreateInfo->format));
1239 }
1240 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001241
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001242 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001243 if (ycbcr_conversion != nullptr) {
1244 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1245 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1246 skip |= LogError(
1247 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1248 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1249 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1250 "r swizzle = %s\n"
1251 "g swizzle = %s\n"
1252 "b swizzle = %s\n"
1253 "a swizzle = %s\n",
1254 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1255 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1256 }
1257 }
1258 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001259 }
1260 return skip;
1261}
1262
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001263bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001264 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001265 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001266
1267 // Note: for numerical correctness
1268 // - float comparisons should expect NaN (comparison always false).
1269 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1270
1271 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001272 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001273 if (v1_f <= 0.0f) return true;
1274
1275 float intpart;
1276 const float fract = modff(v1_f, &intpart);
1277
1278 assert(std::numeric_limits<float>::radix == 2);
1279 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1280 if (intpart >= u32_max_plus1) return false;
1281
1282 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001283 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001284 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001285 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001286 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001287 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001288 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001289 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001290 };
1291
1292 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1293 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1294 return (v1_f <= v2_f);
1295 };
1296
1297 // width
1298 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001299 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001300
1301 if (!(viewport.width > 0.0f)) {
1302 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001303 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1304 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001305 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1306 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001307 skip |= LogError(object, "VUID-VkViewport-width-01771",
1308 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1309 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001310 }
1311
1312 // height
1313 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001314 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001315 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001316
1317 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1318 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001319 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1320 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001321 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1322 height_healthy = false;
1323
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001324 skip |= LogError(object, "VUID-VkViewport-height-01773",
1325 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1326 ").",
1327 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001328 }
1329
1330 // x
1331 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001332 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001333 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001334 skip |= LogError(object, "VUID-VkViewport-x-01774",
1335 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1336 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001337 }
1338
1339 // x + width
1340 if (x_healthy && width_healthy) {
1341 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001342 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001343 skip |= LogError(
1344 object, "VUID-VkViewport-x-01232",
1345 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1346 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1347 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001348 }
1349 }
1350
1351 // y
1352 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001353 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001354 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001355 skip |= LogError(object, "VUID-VkViewport-y-01775",
1356 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1357 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001358 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001359 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001360 skip |= LogError(object, "VUID-VkViewport-y-01776",
1361 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1362 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001363 }
1364
1365 // y + height
1366 if (y_healthy && height_healthy) {
1367 const float boundary = viewport.y + viewport.height;
1368
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001369 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001370 skip |= LogError(object, "VUID-VkViewport-y-01233",
1371 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1372 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1373 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001374 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001375 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001376 LogError(object, "VUID-VkViewport-y-01777",
1377 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1378 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1379 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001380 }
1381 }
1382
sfricke-samsungfd06d422021-01-22 02:17:21 -08001383 // 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 -07001384 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001385 // minDepth
1386 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001387 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001388 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001389 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1390 "[0.0, 1.0] range.",
1391 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001392 }
1393
1394 // maxDepth
1395 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001396 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001397 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001398 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1399 "[0.0, 1.0] range.",
1400 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001401 }
1402 }
1403
1404 return skip;
1405}
1406
Dave Houlton142c4cb2018-10-17 15:04:41 -06001407struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001408 VkShadingRatePaletteEntryNV shadingRate;
1409 uint32_t width;
1410 uint32_t height;
1411};
1412
1413// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001414static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001415 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1416 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1417 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1418 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1419 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1420 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001421};
1422
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001423bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001424 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001425
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001426 SampleOrderInfo *sample_order_info;
1427 uint32_t info_idx = 0;
1428 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1429 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1430 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001431 break;
1432 }
1433 }
1434
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001435 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001436 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1437 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1438 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001439 return skip;
1440 }
1441
Dave Houlton142c4cb2018-10-17 15:04:41 -06001442 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001443 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001444 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1445 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1446 ") must "
1447 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1448 "is set in framebufferNoAttachmentsSampleCounts.",
1449 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001450 }
1451
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001452 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001453 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1454 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1455 ") must "
1456 "be equal to the product of sampleCount (=%" PRIu32
1457 "), the fragment width for shadingRate "
1458 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001459 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001460 }
1461
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001462 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001463 skip |= LogError(
1464 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001465 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1466 ") must "
1467 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001468 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001469 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001470
1471 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001472 // the first width*height*sampleCount bits to all be set. Note: There is no
1473 // guarantee that 64 bits is enough, but practically it's unlikely for an
1474 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001475 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001476 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001477 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001478 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1479 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001480 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1481 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001482 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001483 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001484 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1485 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001486 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001487 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001488 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1489 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001490 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001491 uint32_t idx =
1492 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1493 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001494 }
1495
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001496 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1497 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001498 skip |= LogError(
1499 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001500 "The array pSampleLocations must contain exactly one entry for "
1501 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001502 }
1503
1504 return skip;
1505}
1506
sfricke-samsung51303fb2021-05-09 19:09:13 -07001507bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1508 const VkAllocationCallbacks *pAllocator,
1509 VkPipelineLayout *pPipelineLayout) const {
1510 bool skip = false;
1511 // Validate layout count against device physical limit
1512 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1513 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
1514 "vkCreatePipelineLayout(): setLayoutCount (%d) exceeds physical device maxBoundDescriptorSets limit (%d).",
1515 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1516 }
1517
1518 // Validate Push Constant ranges
1519 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1520 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1521 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1522 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1523 // Check that offset + size don't exceed the max.
1524 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1525 if (offset >= max_push_constants_size) {
1526 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
1527 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) that exceeds this "
1528 "device's maxPushConstantSize of %u.",
1529 i, offset, max_push_constants_size);
1530 }
1531 if (size > max_push_constants_size - offset) {
1532 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
1533 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u] offset (%u) and size (%u) "
1534 "together exceeds this device's maxPushConstantSize of %u.",
1535 i, offset, size, max_push_constants_size);
1536 }
1537
1538 // size needs to be non-zero and a multiple of 4.
1539 if (size == 0) {
1540 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
1541 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not greater than zero.",
1542 i, size);
1543 }
1544 if (size & 0x3) {
1545 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
1546 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not a multiple of 4.", i,
1547 size);
1548 }
1549
1550 // offset needs to be a multiple of 4.
1551 if ((offset & 0x3) != 0) {
1552 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
1553 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) is not a multiple of 4.",
1554 i, offset);
1555 }
1556 }
1557
1558 // 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.
1559 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1560 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1561 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
1562 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1563 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %d and %d.", i, j);
1564 }
1565 }
1566 }
1567 return skip;
1568}
1569
ziga-lunargc6341372021-07-28 12:57:42 +02001570bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1571 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1572 bool skip = false;
1573
1574 const auto *required_subgroup_size_features =
1575 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1576
1577 if (required_subgroup_size_features) {
1578 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1579 skip |= LogError(
1580 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1581 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1582 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1583 func_name, msg, pCreateInfo->flags);
1584 }
1585 }
1586
1587 return skip;
1588}
1589
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001590bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1591 uint32_t createInfoCount,
1592 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1593 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001594 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001595 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001596
1597 if (pCreateInfos != nullptr) {
1598 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001599 bool has_dynamic_viewport = false;
1600 bool has_dynamic_scissor = false;
1601 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001602 bool has_dynamic_depth_bias = false;
1603 bool has_dynamic_blend_constant = false;
1604 bool has_dynamic_depth_bounds = false;
1605 bool has_dynamic_stencil_compare = false;
1606 bool has_dynamic_stencil_write = false;
1607 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001608 bool has_dynamic_viewport_w_scaling_nv = false;
1609 bool has_dynamic_discard_rectangle_ext = false;
1610 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001611 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001612 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001613 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001614 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001615 bool has_dynamic_cull_mode = false;
1616 bool has_dynamic_front_face = false;
1617 bool has_dynamic_primitive_topology = false;
1618 bool has_dynamic_viewport_with_count = false;
1619 bool has_dynamic_scissor_with_count = false;
1620 bool has_dynamic_vertex_input_binding_stride = false;
1621 bool has_dynamic_depth_test_enable = false;
1622 bool has_dynamic_depth_write_enable = false;
1623 bool has_dynamic_depth_compare_op = false;
1624 bool has_dynamic_depth_bounds_test_enable = false;
1625 bool has_dynamic_stencil_test_enable = false;
1626 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001627 bool has_patch_control_points = false;
1628 bool has_rasterizer_discard_enable = false;
1629 bool has_depth_bias_enable = false;
1630 bool has_logic_op = false;
1631 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001632 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001633 if (pCreateInfos[i].pDynamicState != nullptr) {
1634 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1635 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1636 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001637 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1638 if (has_dynamic_viewport == true) {
1639 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1640 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1641 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1642 i);
1643 }
1644 has_dynamic_viewport = true;
1645 }
1646 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1647 if (has_dynamic_scissor == true) {
1648 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1649 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1650 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1651 i);
1652 }
1653 has_dynamic_scissor = true;
1654 }
1655 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1656 if (has_dynamic_line_width == true) {
1657 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1658 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1659 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1660 i);
1661 }
1662 has_dynamic_line_width = true;
1663 }
1664 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1665 if (has_dynamic_depth_bias == true) {
1666 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1667 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1668 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1669 i);
1670 }
1671 has_dynamic_depth_bias = true;
1672 }
1673 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1674 if (has_dynamic_blend_constant == true) {
1675 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1676 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1677 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1678 i);
1679 }
1680 has_dynamic_blend_constant = true;
1681 }
1682 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1683 if (has_dynamic_depth_bounds == true) {
1684 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1685 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1686 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1687 i);
1688 }
1689 has_dynamic_depth_bounds = true;
1690 }
1691 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1692 if (has_dynamic_stencil_compare == true) {
1693 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1694 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1695 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1696 i);
1697 }
1698 has_dynamic_stencil_compare = true;
1699 }
1700 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1701 if (has_dynamic_stencil_write == true) {
1702 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1703 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1704 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1705 i);
1706 }
1707 has_dynamic_stencil_write = true;
1708 }
1709 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1710 if (has_dynamic_stencil_reference == true) {
1711 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1712 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1713 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1714 i);
1715 }
1716 has_dynamic_stencil_reference = true;
1717 }
1718 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1719 if (has_dynamic_viewport_w_scaling_nv == true) {
1720 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1721 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1722 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1723 i);
1724 }
1725 has_dynamic_viewport_w_scaling_nv = true;
1726 }
1727 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1728 if (has_dynamic_discard_rectangle_ext == true) {
1729 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1730 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1731 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1732 i);
1733 }
1734 has_dynamic_discard_rectangle_ext = true;
1735 }
1736 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1737 if (has_dynamic_sample_locations_ext == true) {
1738 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1739 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1740 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1741 i);
1742 }
1743 has_dynamic_sample_locations_ext = true;
1744 }
1745 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1746 if (has_dynamic_exclusive_scissor_nv == true) {
1747 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1748 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1749 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1750 i);
1751 }
1752 has_dynamic_exclusive_scissor_nv = true;
1753 }
1754 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1755 if (has_dynamic_shading_rate_palette_nv == true) {
1756 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1757 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1758 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1759 i);
1760 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001761 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001762 }
1763 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1764 if (has_dynamic_viewport_course_sample_order_nv == true) {
1765 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1766 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1767 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1768 i);
1769 }
1770 has_dynamic_viewport_course_sample_order_nv = true;
1771 }
1772 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1773 if (has_dynamic_line_stipple == true) {
1774 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1775 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1776 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1777 i);
1778 }
1779 has_dynamic_line_stipple = true;
1780 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001781 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1782 if (has_dynamic_cull_mode) {
1783 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1784 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1785 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1786 i);
1787 }
1788 has_dynamic_cull_mode = true;
1789 }
1790 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1791 if (has_dynamic_front_face) {
1792 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1793 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1794 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1795 i);
1796 }
1797 has_dynamic_front_face = true;
1798 }
1799 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1800 if (has_dynamic_primitive_topology) {
1801 skip |= LogError(
1802 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1803 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1804 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1805 i);
1806 }
1807 has_dynamic_primitive_topology = true;
1808 }
1809 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1810 if (has_dynamic_viewport_with_count) {
1811 skip |= LogError(
1812 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1813 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1814 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1815 i);
1816 }
1817 has_dynamic_viewport_with_count = true;
1818 }
1819 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1820 if (has_dynamic_scissor_with_count) {
1821 skip |= LogError(
1822 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1823 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1824 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1825 i);
1826 }
1827 has_dynamic_scissor_with_count = true;
1828 }
1829 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1830 if (has_dynamic_vertex_input_binding_stride) {
1831 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1832 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1833 "listed twice in the "
1834 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1835 i);
1836 }
1837 has_dynamic_vertex_input_binding_stride = true;
1838 }
1839 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1840 if (has_dynamic_depth_test_enable) {
1841 skip |= LogError(
1842 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1843 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1844 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1845 i);
1846 }
1847 has_dynamic_depth_test_enable = true;
1848 }
1849 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1850 if (has_dynamic_depth_write_enable) {
1851 skip |= LogError(
1852 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1853 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1854 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1855 i);
1856 }
1857 has_dynamic_depth_write_enable = true;
1858 }
1859 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1860 if (has_dynamic_depth_compare_op) {
1861 skip |=
1862 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1863 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1864 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1865 i);
1866 }
1867 has_dynamic_depth_compare_op = true;
1868 }
1869 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1870 if (has_dynamic_depth_bounds_test_enable) {
1871 skip |= LogError(
1872 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1873 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1874 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1875 i);
1876 }
1877 has_dynamic_depth_bounds_test_enable = true;
1878 }
1879 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1880 if (has_dynamic_stencil_test_enable) {
1881 skip |= LogError(
1882 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1883 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1884 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1885 i);
1886 }
1887 has_dynamic_stencil_test_enable = true;
1888 }
1889 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1890 if (has_dynamic_stencil_op) {
1891 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1892 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1893 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1894 i);
1895 }
1896 has_dynamic_stencil_op = true;
1897 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001898 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1899 // Not allowed for graphics pipelines
1900 skip |= LogError(
1901 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1902 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1903 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1904 i, state_index);
1905 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001906 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1907 if (has_patch_control_points) {
1908 skip |= LogError(
1909 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1910 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1911 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1912 i);
1913 }
1914 has_patch_control_points = true;
1915 }
1916 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1917 if (has_rasterizer_discard_enable) {
1918 skip |= LogError(
1919 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1920 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1921 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1922 i);
1923 }
1924 has_rasterizer_discard_enable = true;
1925 }
1926 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1927 if (has_depth_bias_enable) {
1928 skip |= LogError(
1929 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1930 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1931 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1932 i);
1933 }
1934 has_depth_bias_enable = true;
1935 }
1936 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1937 if (has_logic_op) {
1938 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1939 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1940 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1941 i);
1942 }
1943 has_logic_op = true;
1944 }
1945 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1946 if (has_primitive_restart_enable) {
1947 skip |= LogError(
1948 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1949 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1950 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1951 i);
1952 }
1953 has_primitive_restart_enable = true;
1954 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001955 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1956 if (has_dynamic_vertex_input) {
1957 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1958 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1959 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1960 i);
1961 }
1962 has_dynamic_vertex_input = true;
1963 }
Petr Kraus299ba622017-11-24 03:09:03 +01001964 }
1965 }
1966
sfricke-samsung3b944422021-01-23 02:15:19 -08001967 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1968 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1969 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1970 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1971 i);
1972 }
1973
1974 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1975 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1976 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1977 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1978 i);
1979 }
1980
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001981 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001982 if ((feedback_struct != nullptr) &&
1983 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001984 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1985 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1986 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1987 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1988 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001989 }
1990
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001991 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001992
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001993 // Collect active stages and other information
1994 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001995 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001996 bool has_eval = false;
1997 bool has_control = false;
1998 if (pCreateInfos[i].pStages != nullptr) {
1999 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
2000 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
2001
2002 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
2003 has_control = true;
2004 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
2005 has_eval = true;
2006 }
2007
2008 skip |= validate_string(
2009 "vkCreateGraphicsPipelines",
2010 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2011 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002012
2013 std::stringstream msg;
2014 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2015 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2016 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002017 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002018 }
2019
2020 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2021 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2022 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2023 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2024 pCreateInfos[i].pTessellationState,
2025 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2026 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2027
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002028 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002029 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2030
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002031 skip |= validate_struct_pnext(
2032 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2033 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2034 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2035 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2036 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2037 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002038
2039 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2040 pCreateInfos[i].pTessellationState->flags,
2041 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2042 }
2043
2044 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2045 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2046 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2047 pCreateInfos[i].pInputAssemblyState,
2048 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2049 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2050
2051 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2052 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002053 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002054
2055 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2056 pCreateInfos[i].pInputAssemblyState->flags,
2057 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2058
2059 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2060 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2061 pCreateInfos[i].pInputAssemblyState->topology,
2062 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2063
2064 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2065 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2066 }
2067
2068 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002069 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002070
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002071 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002072 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2073 "vkCreateGraphicsPipelines: pararameter "
2074 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
2075 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002076 }
2077
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002078 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002079 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2080 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2081 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2082 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002083 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2084 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002085 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002086 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2087 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002088 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002089 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2090 skip |=
2091 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2092 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2093 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2094 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2095 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2096
2097 skip |= validate_array(
2098 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2099 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2100 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2101 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2102
2103 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002104 for (uint32_t vertex_binding_description_index = 0;
2105 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2106 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002107 skip |= validate_ranged_enum(
2108 "vkCreateGraphicsPipelines",
2109 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2110 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002111 pCreateInfos[i]
2112 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2113 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002114 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2115 }
2116 }
2117
2118 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002119 for (uint32_t vertex_attribute_description_index = 0;
2120 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2121 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002122 skip |= validate_ranged_enum(
2123 "vkCreateGraphicsPipelines",
2124 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2125 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002126 pCreateInfos[i]
2127 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2128 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002129 "VUID-VkVertexInputAttributeDescription-format-parameter");
2130 }
2131 }
2132
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002133 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002134 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2135 "vkCreateGraphicsPipelines: pararameter "
2136 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2137 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2138 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002139 }
2140
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002141 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002142 skip |=
2143 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2144 "vkCreateGraphicsPipelines: pararameter "
2145 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2146 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2147 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002148 }
2149
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002150 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002151 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2152 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002153 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2154 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002155 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2156 "vkCreateGraphicsPipelines: parameter "
2157 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2158 "(%" PRIu32 ") is not distinct.",
2159 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002160 }
2161 vertex_bindings.insert(vertex_bind_desc.binding);
2162
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002163 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002164 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2165 "vkCreateGraphicsPipelines: parameter "
2166 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2167 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2168 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002169 }
2170
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002171 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002172 skip |=
2173 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2174 "vkCreateGraphicsPipelines: parameter "
2175 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2176 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2177 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002178 }
2179 }
2180
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002181 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002182 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2183 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002184 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2185 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002186 skip |= LogError(
2187 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002188 "vkCreateGraphicsPipelines: parameter "
2189 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2190 i, d, vertex_attrib_desc.location);
2191 }
2192 attribute_locations.insert(vertex_attrib_desc.location);
2193
2194 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2195 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002196 skip |= LogError(
2197 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002198 "vkCreateGraphicsPipelines: parameter "
2199 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2200 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2201 i, d, vertex_attrib_desc.binding, i);
2202 }
2203
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002204 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002205 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2206 "vkCreateGraphicsPipelines: parameter "
2207 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2208 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2209 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002210 }
2211
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002212 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002213 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2214 "vkCreateGraphicsPipelines: parameter "
2215 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2216 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2217 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002218 }
2219
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002220 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002221 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2222 "vkCreateGraphicsPipelines: parameter "
2223 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2224 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2225 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002226 }
2227 }
2228 }
2229
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002230 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2231 if (has_control && has_eval) {
2232 if (pCreateInfos[i].pTessellationState == nullptr) {
2233 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2234 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2235 "shader stage and a tessellation evaluation shader stage, "
2236 "pCreateInfos[%d].pTessellationState must not be NULL.",
2237 i, i);
2238 } else {
2239 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2240 skip |= validate_struct_pnext(
2241 "vkCreateGraphicsPipelines",
2242 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2243 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2244 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2245 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002246
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002247 skip |= validate_reserved_flags(
2248 "vkCreateGraphicsPipelines",
2249 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2250 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002251
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002252 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2253 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2254 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2255 "vkCreateGraphicsPipelines: invalid parameter "
2256 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2257 "should be >0 and <=%u.",
2258 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2259 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002260 }
2261 }
2262 }
2263
2264 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2265 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2266 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2267 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002268 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2269 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2270 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2271 "].pViewportState (=NULL) is not a valid pointer.",
2272 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002273 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002274 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2275
2276 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002277 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2278 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2279 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2280 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002281 }
2282
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002283 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002284 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002285 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2286 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002287 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2288 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002289 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002290 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002291 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002292 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002293 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002294 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2295 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002296 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2297 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2298 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002299 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002300
2301 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002302 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002303 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002304 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002305
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002306 auto exclusive_scissor_struct =
2307 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2308 auto shading_rate_image_struct =
2309 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2310 auto coarse_sample_order_struct =
2311 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002312 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002313 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002314 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002315 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002316
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002317 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002318 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002319 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2320 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2321 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2322 ") is not 1.",
2323 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002324 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002325
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002326 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002327 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2328 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2329 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2330 ") is not 1.",
2331 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002332 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002333
Dave Houlton142c4cb2018-10-17 15:04:41 -06002334 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2335 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002336 skip |= LogError(
2337 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2338 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2339 "disabled, but pCreateInfos[%" PRIu32
2340 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2341 ") is not 1.",
2342 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002343 }
2344
Jeff Bolz9af91c52018-09-01 21:53:57 -05002345 if (shading_rate_image_struct &&
2346 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002347 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2348 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2349 "disabled, but pCreateInfos[%" PRIu32
2350 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2351 ") is neither 0 nor 1.",
2352 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002353 }
2354
Petr Krausa6103552017-11-16 21:21:58 +01002355 } else { // multiViewport enabled
2356 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002357 if (!has_dynamic_viewport_with_count) {
2358 skip |= LogError(
2359 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2360 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2361 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002362 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002363 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2364 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2365 "].pViewportState->viewportCount (=%" PRIu32
2366 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2367 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002368 } else if (has_dynamic_viewport_with_count) {
2369 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2370 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2371 "].pViewportState->viewportCount (=%" PRIu32
2372 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2373 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002374 }
Petr Krausa6103552017-11-16 21:21:58 +01002375
2376 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002377 if (!has_dynamic_scissor_with_count) {
2378 skip |= LogError(
2379 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2380 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2381 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002382 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002383 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2384 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2385 "].pViewportState->scissorCount (=%" PRIu32
2386 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2387 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002388 } else if (has_dynamic_scissor_with_count) {
2389 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2390 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2391 "].pViewportState->scissorCount (=%" PRIu32
2392 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2393 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002394 }
2395 }
2396
ziga-lunarg845883b2021-07-14 15:05:00 +02002397 if (!has_dynamic_scissor && viewport_state.pScissors) {
2398 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2399 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002400
2401 if (scissor.offset.x < 0) {
2402 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2403 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2404 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2405 scissor.offset.x, i, scissor_i);
2406 }
2407
2408 if (scissor.offset.y < 0) {
2409 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2410 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2411 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2412 scissor.offset.y, i, scissor_i);
2413 }
2414
ziga-lunarg845883b2021-07-14 15:05:00 +02002415 const int64_t x_sum =
2416 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2417 if (x_sum > std::numeric_limits<int32_t>::max()) {
2418 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2419 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2420 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2421 "] will overflow int32_t.",
2422 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2423 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002424
ziga-lunarg845883b2021-07-14 15:05:00 +02002425 const int64_t y_sum =
2426 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2427 if (y_sum > std::numeric_limits<int32_t>::max()) {
2428 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2429 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2430 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2431 "] will overflow int32_t.",
2432 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2433 }
2434 }
2435 }
2436
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002437 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002438 skip |=
2439 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2440 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2441 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2442 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002443 }
2444
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002445 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002446 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2447 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2448 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2449 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2450 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002451 }
2452
Piers Daniell39842ee2020-07-10 16:42:33 -06002453 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2454 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002455 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2456 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2457 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2458 "].pViewportState->viewportCount (=%" PRIu32 ").",
2459 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002460 }
2461
Dave Houlton142c4cb2018-10-17 15:04:41 -06002462 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002463 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002464 skip |=
2465 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2466 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2467 ") must be zero or identical to pCreateInfos[%" PRIu32
2468 "].pViewportState->viewportCount (=%" PRIu32 ").",
2469 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002470 }
2471
Dave Houlton142c4cb2018-10-17 15:04:41 -06002472 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002473 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002474 skip |= LogError(
2475 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002476 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2477 "] "
2478 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2479 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2480 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002481 }
2482
Petr Krausa6103552017-11-16 21:21:58 +01002483 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002484 skip |= LogError(
2485 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002486 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2487 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002488 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2489 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002490 }
2491
2492 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002493 skip |= LogError(
2494 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002495 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2496 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002497 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2498 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002499 }
2500
Jeff Bolz3e71f782018-08-29 23:15:45 -05002501 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002502 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2503 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2504 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002505 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002506 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2507 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2508 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2509 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002510 }
2511
Jeff Bolz9af91c52018-09-01 21:53:57 -05002512 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002513 shading_rate_image_struct->viewportCount > 0 &&
2514 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002515 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002516 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002517 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002518 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2519 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002520 i, i);
2521 }
2522
Chris Mayer328d8212018-12-11 14:16:18 +01002523 if (vp_swizzle_struct) {
2524 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002525 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2526 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2527 " does "
2528 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2529 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002530 }
2531 }
2532
Petr Krausb3fcdb42018-01-09 22:09:09 +01002533 // validate the VkViewports
2534 if (!has_dynamic_viewport && viewport_state.pViewports) {
2535 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2536 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002537 const char *fn_name = "vkCreateGraphicsPipelines";
2538 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2539 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2540 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002541 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002542 }
2543 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002544
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002545 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002546 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2547 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2548 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2549 "VK_NV_clip_space_w_scaling extension is not enabled.",
2550 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002551 }
2552
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002553 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002554 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2555 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2556 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2557 "VK_EXT_discard_rectangles extension is not enabled.",
2558 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002559 }
2560
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002561 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002562 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2563 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2564 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2565 "VK_EXT_sample_locations extension is not enabled.",
2566 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002567 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002568
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002569 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002570 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2571 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2572 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2573 "VK_NV_scissor_exclusive extension is not enabled.",
2574 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002575 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002576
2577 if (coarse_sample_order_struct &&
2578 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2579 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002580 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2581 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2582 "] "
2583 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2584 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2585 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002586 }
2587
2588 if (coarse_sample_order_struct) {
2589 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002590 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002591 }
2592 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002593
2594 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2595 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002596 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2597 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2598 "] "
2599 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2600 ") "
2601 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2602 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002603 }
2604 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002605 skip |= LogError(
2606 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002607 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2608 "] "
2609 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2610 i);
2611 }
2612 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002613 }
2614
2615 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002616 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2617 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2618 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2619 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002620 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002621 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002622 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002623 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2624 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002625 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002626 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002627 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002628 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002629 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002630 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002631 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002632 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2633 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002634
2635 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002636 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002637 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002638 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002639
2640 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002641 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002642 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2643 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2644
2645 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002646 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002647 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2648 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002649 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002650 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002651
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002652 skip |= validate_flags(
2653 "vkCreateGraphicsPipelines",
2654 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2655 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002656 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002657
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002658 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002659 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002660 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2661 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2662
2663 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002664 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002665 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2666 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2667
2668 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002669 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002670 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2671 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2672 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002673 }
John Zulauf7acac592017-11-06 11:15:53 -07002674 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002675 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002676 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2677 "vkCreateGraphicsPipelines(): parameter "
2678 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2679 i);
John Zulauf7acac592017-11-06 11:15:53 -07002680 }
2681 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2682 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2683 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002684 skip |= LogError(
2685 device,
2686
Dave Houlton413a6782018-05-22 13:01:54 -06002687 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002688 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002689 }
2690 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002691
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002692 const auto *line_state =
2693 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002694
2695 if (line_state) {
2696 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2697 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2698 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2699 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002700 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2701 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2702 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2703 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002704 }
2705 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2706 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002707 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2708 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2709 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2710 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002711 }
2712 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2713 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002714 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2715 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2716 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2717 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002718 }
2719 }
2720 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2721 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2722 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002723 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2724 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2725 "range [1,256].",
2726 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002727 }
2728 }
2729 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002730 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002731 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2732 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002733 skip |=
2734 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2735 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2736 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2737 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002738 }
2739 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2740 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002741 skip |=
2742 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2743 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2744 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2745 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002746 }
2747 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2748 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002749 skip |=
2750 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2751 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2752 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2753 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002754 }
2755 if (line_state->stippledLineEnable) {
2756 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2757 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002758 skip |=
2759 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2760 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2761 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2762 "stippledRectangularLines feature.",
2763 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002764 }
2765 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2766 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002767 skip |=
2768 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2769 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2770 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2771 "stippledBresenhamLines feature.",
2772 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002773 }
2774 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2775 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002776 skip |=
2777 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2778 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2779 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2780 "stippledSmoothLines feature.",
2781 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002782 }
2783 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2784 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002785 skip |=
2786 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2787 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2788 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2789 "stippledRectangularLines and strictLines features.",
2790 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002791 }
2792 }
2793 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002794 }
2795
Petr Krause91f7a12017-12-14 20:57:36 +01002796 bool uses_color_attachment = false;
2797 bool uses_depthstencil_attachment = false;
2798 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002799 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002800 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2801 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002802 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002803 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002804 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002805 }
2806 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002807 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002808 }
Petr Krause91f7a12017-12-14 20:57:36 +01002809 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002810 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002811 }
2812
2813 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002814 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002815 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002816 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002817 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002818 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002819
2820 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002821 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002823 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002824
2825 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002826 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002827 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2828 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2829
2830 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002831 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002832 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2833 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2834
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->depthCompareOp", ParameterName::IndexVector{i}),
2838 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002839 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002840
2841 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002842 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002843 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2844 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2845
2846 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002847 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002848 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2849 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2850
2851 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002852 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002853 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2854 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002855 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002856
2857 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002858 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002859 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2860 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002861 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002862
2863 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002864 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002865 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2866 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002867 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002868
2869 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002870 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002871 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2872 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002873 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002874
2875 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002876 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002877 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2878 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002879 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002880
2881 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002882 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002883 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2884 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002885 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002886
2887 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002888 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002889 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2890 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002891 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892
2893 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002894 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002895 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2896 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002897 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002898
2899 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002900 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002901 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2902 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2903 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002904 }
2905 }
2906
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002907 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002908 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2909
Petr Krause91f7a12017-12-14 20:57:36 +01002910 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002911 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2912 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2913 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2914 pCreateInfos[i].pColorBlendState,
2915 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2916 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2917
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002918 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002919 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002920 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2921 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002922 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2923 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002924 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2925 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002926
2927 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002928 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002929 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002930 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002931
2932 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002933 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002934 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2935 pCreateInfos[i].pColorBlendState->logicOpEnable);
2936
2937 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002938 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002939 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2940 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002941 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002942 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002943
2944 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002945 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2946 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002947 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002948 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002949 ParameterName::IndexVector{i, attachment_index}),
2950 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002951
2952 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002953 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002954 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002955 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002957 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002958 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002959
2960 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002961 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002963 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002965 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002966 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002967
2968 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002969 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002971 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002972 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002973 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002974 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002975
2976 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002977 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002978 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002979 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002980 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002981 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002982 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002983
2984 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002985 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002986 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002987 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002988 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002989 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002990 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002991
2992 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002993 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002994 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002995 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002996 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002997 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002998 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002999
3000 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003001 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003002 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003003 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003004 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003005 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003006 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003007 }
3008 }
3009
3010 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003011 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003012 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
3013 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3014 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003015 }
3016
3017 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3018 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3019 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003020 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003021 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003022 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3023 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003024 }
3025 }
3026 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003027
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003028 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3029 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003030 if (pCreateInfos[i].basePipelineIndex != -1) {
3031 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003032 skip |=
3033 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003034 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003035 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003036 "and pCreateInfos->basePipelineIndex is not -1.",
3037 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003038 }
3039 }
3040
Petr Kraus9752aae2017-11-24 03:05:50 +01003041 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3042 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003043 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003044 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003045 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003046 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3047 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003048 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003049 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003050 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003051 skip |=
3052 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
3053 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
3054 "index into the pCreateInfos array, of size %d.",
3055 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003056 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003057 }
3058 }
3059
Petr Kraus9752aae2017-11-24 03:05:50 +01003060 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003061 if (!device_extensions.vk_nv_fill_rectangle) {
3062 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3063 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003064 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3065 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3066 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3067 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003068 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3069 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003070 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003071 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003072 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
3073 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3074 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003075 }
3076 } else {
3077 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3078 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3079 (physical_device_features.fillModeNonSolid == false)) {
3080 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003081 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3082 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003083 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
3084 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3085 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003086 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003087 }
Petr Kraus299ba622017-11-24 03:09:03 +01003088
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003089 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003090 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003091 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3092 "The line width state is static (pCreateInfos[%" PRIu32
3093 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3094 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3095 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3096 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003097 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003098 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003099
3100 // Validate no flags not allowed are used
3101 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003102 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
3103 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3104 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3105 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003106 }
3107 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003108 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
3109 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3110 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3111 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003112 }
3113 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3114 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07003115 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3116 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3117 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003118 }
3119 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3120 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07003121 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3122 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3123 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003124 }
3125 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3126 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07003127 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3128 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3129 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003130 }
3131 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3132 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003133 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3134 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3135 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003136 }
3137 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3138 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003139 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3140 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3141 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003142 }
3143 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3144 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003145 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3146 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3147 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003148 }
3149 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3150 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003151 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3152 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3153 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003154 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003155 }
3156 }
3157
3158 return skip;
3159}
3160
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003161bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3162 uint32_t createInfoCount,
3163 const VkComputePipelineCreateInfo *pCreateInfos,
3164 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003165 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003166 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003167 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003168 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003169 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003170 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003171 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003172 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003173 skip |=
3174 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3175 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3176 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3177 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003178 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003179
3180 // Make sure compute stage is selected
3181 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003182 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3183 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3184 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003185 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003186
sfricke-samsungeb549012021-04-16 01:25:51 -07003187 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3188 // Validate no flags not allowed are used
3189 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3190 skip |= LogError(
3191 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3192 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3193 i, flags);
3194 }
3195 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3196 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3197 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3198 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3199 i, flags);
3200 }
3201 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3202 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3203 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3204 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3205 i, flags);
3206 }
3207 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3208 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3209 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3210 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3211 i, flags);
3212 }
3213 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3214 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3215 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3216 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3217 i, flags);
3218 }
3219 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3220 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3221 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3222 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3223 i, flags);
3224 }
3225 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3226 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3227 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3228 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3229 i, flags);
3230 }
3231 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3232 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3233 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3234 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3235 i, flags);
3236 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003237 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3238 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
3239 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3240 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3241 i, flags);
3242 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003243 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3244 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3245 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3246 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3247 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003248 }
ziga-lunargc6341372021-07-28 12:57:42 +02003249
3250 std::stringstream msg;
3251 msg << "pCreateInfos[%" << i << "].stage";
3252 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003253 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003254 return skip;
3255}
3256
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003257bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003258 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003259 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003260
3261 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003262 const auto &features = physical_device_features;
3263 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003264
John Zulauf71968502017-10-26 13:51:15 -06003265 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3266 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003267 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3268 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3269 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3270 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003271 }
3272
3273 // Anistropy cannot be enabled in sampler unless enabled as a feature
3274 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003275 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3276 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3277 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003278 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003279 }
John Zulauf71968502017-10-26 13:51:15 -06003280
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003281 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3282 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003283 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3284 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3285 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3286 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003287 }
3288 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003289 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3290 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3291 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3292 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003293 }
3294 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003295 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3296 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3297 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3298 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003299 }
3300 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3301 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3302 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3303 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003304 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3305 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3306 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3307 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3308 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3309 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003310 }
3311 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003312 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3313 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3314 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003315 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003316 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003317 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3318 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3319 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003320 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003321 }
3322
3323 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3324 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003325 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3326 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003327 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003328 if (sampler_reduction != nullptr) {
3329 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3330 skip |= LogError(
3331 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3332 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3333 }
3334 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003335 }
3336
3337 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3338 // valid VkBorderColor value
3339 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3340 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3341 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003342 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3343 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003344 }
3345
John Zulauf275805c2017-10-26 15:34:49 -06003346 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003347 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003348 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3349 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003350 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3351 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3352 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003353 }
3354 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003355
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003356 // Check for valid Lod range
3357 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003358 skip |=
3359 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3360 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003361 }
3362
3363 // Check mipLodBias to device limit
3364 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003365 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3366 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3367 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003368 }
3369
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003370 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003371 if (sampler_conversion != nullptr) {
3372 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3373 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3374 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3375 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003376 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003377 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003378 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3379 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3380 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3381 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3382 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3383 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3384 }
3385 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003386
3387 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3388 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3389 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3390 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3391 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3392 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3393 }
3394 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3395 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3396 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3397 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3398 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3399 }
3400 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3401 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3402 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3403 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3404 pCreateInfo->minLod, pCreateInfo->maxLod);
3405 }
3406 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3407 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3408 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3409 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3410 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3411 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3412 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3413 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3414 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3415 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3416 }
3417 if (pCreateInfo->anisotropyEnable) {
3418 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3419 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3420 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3421 }
3422 if (pCreateInfo->compareEnable) {
3423 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3424 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3425 "pCreateInfo->compareEnable must be VK_FALSE");
3426 }
3427 if (pCreateInfo->unnormalizedCoordinates) {
3428 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3429 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3430 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3431 }
3432 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433 }
3434
Tony-LunarG7337b312020-04-15 16:40:25 -06003435 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3436 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3437 if (!device_extensions.vk_ext_custom_border_color) {
3438 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3439 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3440 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3441 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003442 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003443 if (!custom_create_info) {
3444 skip |=
3445 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3446 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3447 "struct in pNext chain.\n",
3448 string_VkBorderColor(pCreateInfo->borderColor));
3449 } else {
3450 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3451 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3452 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3453 !FormatIsSampledFloat(custom_create_info->format)))) {
3454 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3455 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3456 "whose type does not match\n",
3457 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3458 ;
3459 }
3460 }
3461 }
3462
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003463 return skip;
3464}
3465
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003466bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3467 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3468 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003469 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003470 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003471
3472 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3473 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3474 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3475 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003476 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3477 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3478 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3479 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3480 ++descriptor_index) {
3481 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003482 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003483 "vkCreateDescriptorSetLayout: required parameter "
3484 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3485 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003486 }
3487 }
3488 }
3489
3490 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3491 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3492 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003493 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3494 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3495 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3496 "values.",
3497 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003498 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003499
3500 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3501 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3502 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3503 skip |=
3504 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3505 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3506 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3507 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3508 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3509 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003510 }
3511 }
3512 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003513 return skip;
3514}
3515
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003516bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3517 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003518 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003519 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3520 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3521 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003522 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3523 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003524}
3525
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003526bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3527 const VkWriteDescriptorSet *pDescriptorWrites,
3528 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003529 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003530
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003531 if (pDescriptorWrites != NULL) {
3532 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3533 // descriptorCount must be greater than 0
3534 if (pDescriptorWrites[i].descriptorCount == 0) {
3535 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003536 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3537 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003538 }
3539
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003540 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3541 if (validateDstSet) {
3542 // dstSet must be a valid VkDescriptorSet handle
3543 skip |= validate_required_handle(vkCallingFunction,
3544 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3545 pDescriptorWrites[i].dstSet);
3546 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003547
3548 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3549 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3550 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3551 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3552 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3553 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3554 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003555 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3556 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003557 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003558 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3559 "%s(): if pDescriptorWrites[%d].descriptorType is "
3560 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3561 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3562 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3563 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003564 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3565 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003566 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3567 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003568 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3569 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003570 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003571 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3572 ParameterName::IndexVector{i, descriptor_index}),
3573 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003574 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003575 }
3576 }
3577 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3578 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3579 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3580 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3581 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3582 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3583 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003584 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003585 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003586 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3587 "%s(): if pDescriptorWrites[%d].descriptorType is "
3588 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3589 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3590 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3591 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003592 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003593 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003594 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003595 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003596 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3597 ++descriptor_index) {
3598 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3599 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3600 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003601 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3602 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003603 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003604 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3605 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003606 }
3607 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003608 }
3609 }
3610 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3611 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003612 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003613 }
3614
3615 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3616 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003617 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003618 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3619 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003620 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003621 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003622 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3623 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3624 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003625 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003626 }
3627 }
3628 }
3629 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3630 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003631 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003632 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3633 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003634 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003635 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003636 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3637 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3638 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003639 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003640 }
3641 }
3642 }
3643 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003644 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3645 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003646 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003647 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003648 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3649 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3650 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3651 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3652 "accelerationStructureCount %d member equals descriptorCount %d.",
3653 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3654 pDescriptorWrites[i].descriptorCount);
3655 }
3656 // further checks only if we have right structtype
3657 if (pnext_struct) {
3658 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3659 skip |= LogError(
3660 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3661 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3662 ".",
3663 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003664 }
sourav parmarbcee7512020-12-28 14:34:49 -08003665 if (pnext_struct->accelerationStructureCount == 0) {
3666 skip |= LogError(device,
3667 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003668 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003669 }
3670 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003671 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003672 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3673 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3674 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3675 skip |= LogError(device,
3676 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3677 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003678 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003679 }
3680 }
3681 }
sourav parmarbcee7512020-12-28 14:34:49 -08003682 }
3683 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003684 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003685 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3686 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3687 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3688 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3689 "accelerationStructureCount %d member equals descriptorCount %d.",
3690 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3691 pDescriptorWrites[i].descriptorCount);
3692 }
3693 // further checks only if we have right structtype
3694 if (pnext_struct) {
3695 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3696 skip |= LogError(
3697 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3698 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3699 ".",
3700 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003701 }
sourav parmarbcee7512020-12-28 14:34:49 -08003702 if (pnext_struct->accelerationStructureCount == 0) {
3703 skip |= LogError(device,
3704 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003705 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003706 }
3707 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003708 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003709 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3710 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3711 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3712 skip |= LogError(device,
3713 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3714 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003715 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003716 }
3717 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003718 }
3719 }
3720 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003721 }
3722 }
3723 return skip;
3724}
3725
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003726bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3727 const VkWriteDescriptorSet *pDescriptorWrites,
3728 uint32_t descriptorCopyCount,
3729 const VkCopyDescriptorSet *pDescriptorCopies) const {
3730 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3731}
3732
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003733bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003734 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003735 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003736 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3737}
3738
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003739bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3740 const VkAllocationCallbacks *pAllocator,
3741 VkRenderPass *pRenderPass) const {
3742 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3743}
3744
Mike Schuchardt2df08912020-12-15 16:28:09 -08003745bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003746 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003747 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003748 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3749}
3750
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003751bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3752 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003753 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003754 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003755
3756 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3757 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3758 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003759 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3760 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003761 return skip;
3762}
3763
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003764bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003765 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003766 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003767
3768 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3769 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003770 bool cb_is_secondary;
3771 {
3772 auto lock = cb_read_lock();
3773 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3774 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003775
Tony-LunarG3c287f62020-12-17 12:39:49 -07003776 if (cb_is_secondary) {
3777 // Implicit VUs
3778 // validate only sType here; pointer has to be validated in core_validation
3779 const bool k_not_required = false;
3780 const char *k_no_vuid = nullptr;
3781 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3782 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003783 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3784 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003785
Tony-LunarG3c287f62020-12-17 12:39:49 -07003786 if (info) {
3787 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003788 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3789 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003790 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003791 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3792 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3793 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3794 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003795
Tony-LunarG3c287f62020-12-17 12:39:49 -07003796 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003797
Tony-LunarG3c287f62020-12-17 12:39:49 -07003798 // Explicit VUs
3799 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003800 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003801 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3802 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3803 cmd_name);
3804 }
3805
3806 if (physical_device_features.inheritedQueries) {
3807 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003808 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3809 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3810 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003811 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003812 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003813 }
3814
3815 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003816 skip |=
3817 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3818 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3819 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3820 } else { // !pipelineStatisticsQuery
3821 skip |=
3822 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3823 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003824 }
3825
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003826 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003827 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003828 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003829 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3830 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3831 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003832 commandBuffer,
3833 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003834 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3835 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3836 }
Petr Kraus139757b2019-08-15 17:19:33 +02003837 }
ziga-lunarg9d019132021-07-19 01:05:31 +02003838
3839 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
3840 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
3841 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
3842 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
3843 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
3844 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
3845 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
3846 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
3847 }
Petr Kraus139757b2019-08-15 17:19:33 +02003848 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003849 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003850 return skip;
3851}
3852
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003853bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003854 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003855 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003856
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003857 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003858 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003859 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3860 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3861 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003862 }
3863 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003864 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3865 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3866 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003867 }
3868 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003869 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003870 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003871 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3872 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3873 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3874 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003875 }
3876 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003877
3878 if (pViewports) {
3879 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3880 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003881 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003882 skip |= manual_PreCallValidateViewport(
3883 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003884 }
3885 }
3886
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003887 return skip;
3888}
3889
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003890bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003891 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003892 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003893
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003894 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003895 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003896 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3897 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3898 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003899 }
3900 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003901 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3902 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3903 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003904 }
3905 } else { // multiViewport enabled
3906 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003907 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003908 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3909 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3910 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3911 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003912 }
3913 }
3914
Petr Kraus6260f0a2018-02-27 21:15:55 +01003915 if (pScissors) {
3916 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3917 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003918
Petr Kraus6260f0a2018-02-27 21:15:55 +01003919 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003920 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3921 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3922 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003923 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003924
Petr Kraus6260f0a2018-02-27 21:15:55 +01003925 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003926 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3927 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3928 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003929 }
3930
3931 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3932 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003933 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3934 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3935 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3936 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003937 }
3938
3939 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3940 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003941 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3942 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3943 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3944 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003945 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003946 }
3947 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003948
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003949 return skip;
3950}
3951
Jeff Bolz5c801d12019-10-09 10:38:45 -05003952bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003953 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003954
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003955 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003956 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3957 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003958 }
3959
3960 return skip;
3961}
3962
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003963bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003964 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003965 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003966
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003967 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003968 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003969 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3970 }
3971 if (drawCount > device_limits.maxDrawIndirectCount) {
3972 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003973 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3974 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003975 }
3976 return skip;
3977}
3978
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003979bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003980 VkDeviceSize offset, uint32_t drawCount,
3981 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003982 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003983 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003984 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3985 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3986 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003987 }
3988 if (drawCount > device_limits.maxDrawIndirectCount) {
3989 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003990 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3991 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003992 }
3993 return skip;
3994}
3995
sfricke-samsungf692b972020-05-02 08:00:45 -07003996bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3997 VkDeviceSize countBufferOffset, bool khr) const {
3998 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003999 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004000 if (offset & 3) {
4001 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004002 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004003 }
4004
4005 if (countBufferOffset & 3) {
4006 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004007 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004008 countBufferOffset);
4009 }
4010 return skip;
4011}
4012
4013bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4014 VkDeviceSize offset, VkBuffer countBuffer,
4015 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4016 uint32_t stride) const {
4017 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4018}
4019
4020bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4021 VkDeviceSize offset, VkBuffer countBuffer,
4022 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4023 uint32_t stride) const {
4024 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4025}
4026
4027bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4028 VkDeviceSize countBufferOffset, bool khr) const {
4029 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004030 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004031 if (offset & 3) {
4032 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004033 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004034 }
4035
4036 if (countBufferOffset & 3) {
4037 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004038 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004039 countBufferOffset);
4040 }
4041 return skip;
4042}
4043
4044bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4045 VkDeviceSize offset, VkBuffer countBuffer,
4046 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4047 uint32_t stride) const {
4048 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4049}
4050
4051bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4052 VkDeviceSize offset, VkBuffer countBuffer,
4053 VkDeviceSize countBufferOffset,
4054 uint32_t maxDrawCount, uint32_t stride) const {
4055 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4056}
4057
Tony-LunarG4490de42021-06-21 15:49:19 -06004058bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4059 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4060 uint32_t firstInstance, uint32_t stride) const {
4061 bool skip = false;
4062 if (stride & 3) {
4063 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4064 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4065 }
4066 if (drawCount && nullptr == pVertexInfo) {
4067 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4068 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4069 "one or more valid instances of VkMultiDrawInfoEXT structures");
4070 }
4071 return skip;
4072}
4073
4074bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4075 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4076 uint32_t instanceCount, uint32_t firstInstance,
4077 uint32_t stride, const int32_t *pVertexOffset) const {
4078 bool skip = false;
4079 if (stride & 3) {
4080 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4081 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4082 }
4083 if (drawCount && nullptr == pIndexInfo) {
4084 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4085 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4086 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4087 }
4088 return skip;
4089}
4090
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004091bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4092 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004093 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004094 bool skip = false;
4095 for (uint32_t rect = 0; rect < rectCount; rect++) {
4096 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004097 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
4098 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004099 }
sfricke-samsung10867682020-04-25 02:20:39 -07004100 if (pRects[rect].rect.extent.width == 0) {
4101 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
4102 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
4103 }
4104 if (pRects[rect].rect.extent.height == 0) {
4105 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
4106 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
4107 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004108 }
4109 return skip;
4110}
4111
Andrew Fobel3abeb992020-01-20 16:33:22 -05004112bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4113 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4114 VkImageFormatProperties2 *pImageFormatProperties,
4115 const char *apiName) const {
4116 bool skip = false;
4117
4118 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004119 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004120 if (image_stencil_struct != nullptr) {
4121 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4122 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4123 // No flags other than the legal attachment bits may be set
4124 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4125 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004126 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4127 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4128 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4129 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4130 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004131 }
4132 }
4133 }
4134 }
4135
4136 return skip;
4137}
4138
4139bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4140 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4141 VkImageFormatProperties2 *pImageFormatProperties) const {
4142 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4143 "vkGetPhysicalDeviceImageFormatProperties2");
4144}
4145
4146bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4147 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4148 VkImageFormatProperties2 *pImageFormatProperties) const {
4149 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4150 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4151}
4152
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004153bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4154 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4155 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4156 bool skip = false;
4157
4158 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4159 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4160 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4161 }
4162
4163 return skip;
4164}
4165
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004166bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4167 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4168 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4169 bool skip = false;
4170
4171 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4172 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4173 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4174 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4175 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4176 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4177 }
4178
4179 return false;
4180}
4181
sfricke-samsung3999ef62020-02-09 17:05:59 -08004182bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4183 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4184 bool skip = false;
4185
4186 if (pRegions != nullptr) {
4187 for (uint32_t i = 0; i < regionCount; i++) {
4188 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004189 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4190 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004191 }
4192 }
4193 }
4194 return skip;
4195}
4196
Jeff Leger178b1e52020-10-05 12:22:23 -04004197bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4198 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4199 bool skip = false;
4200
4201 if (pCopyBufferInfo->pRegions != nullptr) {
4202 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4203 if (pCopyBufferInfo->pRegions[i].size == 0) {
4204 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4205 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4206 }
4207 }
4208 }
4209 return skip;
4210}
4211
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004212bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004213 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4214 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004215 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004216
4217 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004218 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4219 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4220 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004221 }
4222
4223 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004224 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4225 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4226 "), must be greater than zero and less than or equal to 65536.",
4227 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004228 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004229 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4230 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4231 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004232 }
4233 return skip;
4234}
4235
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004236bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004237 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004238 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004239
4240 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004241 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4242 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4243 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004244 }
4245
4246 if (size != VK_WHOLE_SIZE) {
4247 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004248 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004249 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4250 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004251 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004252 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4253 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004254 }
4255 }
4256 return skip;
4257}
4258
sfricke-samsunga1d00272021-03-10 21:37:41 -08004259bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004260 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004261
4262 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004263 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4264 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4265 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4266 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004267 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004268 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4269 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4270 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004271 }
4272
4273 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4274 // queueFamilyIndexCount uint32_t values
4275 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004276 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004277 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004278 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004279 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4280 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004281 }
4282 }
4283
Dave Houlton413a6782018-05-22 13:01:54 -06004284 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004285 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004286
sfricke-samsunga1d00272021-03-10 21:37:41 -08004287 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4288 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4289 if (format_list_info) {
4290 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4291 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4292 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4293 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4294 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4295 func_name, viewFormatCount);
4296 }
4297
4298 // Using the first format, compare the rest of the formats against it that they are compatible
4299 for (uint32_t i = 1; i < viewFormatCount; i++) {
4300 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4301 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4302 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4303 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4304 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4305 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4306 string_VkFormat(format_list_info->pViewFormats[i]));
4307 }
4308 }
4309 }
4310
4311 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4312 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4313 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4314 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4315 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4316 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4317 func_name);
4318 } else {
4319 if (format_list_info == nullptr) {
4320 skip |= LogError(
4321 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4322 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4323 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4324 func_name);
4325 } else if (format_list_info->viewFormatCount == 0) {
4326 skip |= LogError(
4327 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4328 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4329 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4330 func_name);
4331 } else {
4332 bool found_base_format = false;
4333 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4334 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4335 found_base_format = true;
4336 break;
4337 }
4338 }
4339 if (!found_base_format) {
4340 skip |=
4341 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4342 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4343 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4344 "pCreateInfo->imageFormat.",
4345 func_name);
4346 }
4347 }
4348 }
4349 }
4350 }
4351 return skip;
4352}
4353
4354bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4355 const VkAllocationCallbacks *pAllocator,
4356 VkSwapchainKHR *pSwapchain) const {
4357 bool skip = false;
4358 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4359 return skip;
4360}
4361
4362bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4363 const VkSwapchainCreateInfoKHR *pCreateInfos,
4364 const VkAllocationCallbacks *pAllocator,
4365 VkSwapchainKHR *pSwapchains) const {
4366 bool skip = false;
4367 if (pCreateInfos) {
4368 for (uint32_t i = 0; i < swapchainCount; i++) {
4369 std::stringstream func_name;
4370 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4371 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4372 }
4373 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004374 return skip;
4375}
4376
Jeff Bolz5c801d12019-10-09 10:38:45 -05004377bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004378 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004379
4380 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004381 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004382 if (present_regions) {
4383 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004384 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004385 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4386 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004387 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004388 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4389 "extension swapchainCount is %i. These values must be equal.",
4390 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004391 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004392 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004393 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4394 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004395 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4396 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4397 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004398 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004399 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004400 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004401 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004402 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004403 }
4404 }
4405
4406 return skip;
4407}
4408
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004409bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4410 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4411 const VkAllocationCallbacks *pAllocator,
4412 VkDisplayModeKHR *pMode) const {
4413 bool skip = false;
4414
4415 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4416 if (display_mode_parameters.visibleRegion.width == 0) {
4417 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4418 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4419 }
4420 if (display_mode_parameters.visibleRegion.height == 0) {
4421 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4422 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4423 }
4424 if (display_mode_parameters.refreshRate == 0) {
4425 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4426 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4427 }
4428
4429 return skip;
4430}
4431
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004432#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004433bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4434 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4435 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004436 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004437 bool skip = false;
4438
4439 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004440 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4441 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004442 }
4443
4444 return skip;
4445}
4446#endif // VK_USE_PLATFORM_WIN32_KHR
4447
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004448bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004449 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004450 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004451 bool skip = false;
4452
4453 if (pCreateInfo) {
4454 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004455 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4456 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004457 }
4458
4459 if (pCreateInfo->pPoolSizes) {
4460 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4461 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004462 skip |= LogError(
4463 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004464 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004465 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004466 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4467 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004468 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4469 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4470 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4471 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4472 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004473 }
Petr Krausc8655be2017-09-27 18:56:51 +02004474 }
4475 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004476
4477 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4478 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4479 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4480 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4481 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4482 }
Petr Krausc8655be2017-09-27 18:56:51 +02004483 }
4484
4485 return skip;
4486}
4487
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004488bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004489 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004490 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004491
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004492 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004493 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004494 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4495 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4496 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004497 }
4498
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004499 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004500 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004501 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4502 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4503 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004504 }
4505
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004506 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004507 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004508 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4509 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4510 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004511 }
4512
4513 return skip;
4514}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004515
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004516bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004517 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004518 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004519
4520 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004521 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4522 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004523 }
4524 return skip;
4525}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004526
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004527bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4528 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004529 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004530 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004531
4532 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004533 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004534 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004535 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4536 "vkCmdDispatch(): baseGroupX (%" PRIu32
4537 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4538 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004539 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004540 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4541 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4542 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4543 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004544 }
4545
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004546 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004547 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004548 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4549 "vkCmdDispatch(): baseGroupY (%" PRIu32
4550 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4551 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004552 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004553 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4554 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4555 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4556 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004557 }
4558
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004559 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004560 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004561 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4562 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4563 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4564 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004565 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004566 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4567 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4568 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4569 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004570 }
4571
4572 return skip;
4573}
4574
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004575bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4576 VkPipelineBindPoint pipelineBindPoint,
4577 VkPipelineLayout layout, uint32_t set,
4578 uint32_t descriptorWriteCount,
4579 const VkWriteDescriptorSet *pDescriptorWrites) const {
4580 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4581}
4582
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004583bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4584 uint32_t firstExclusiveScissor,
4585 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004586 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004587 bool skip = false;
4588
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004589 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004590 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004591 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004592 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4593 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4594 ") is not 0.",
4595 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004596 }
4597 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004598 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004599 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4600 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4601 ") is not 1.",
4602 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004603 }
4604 } else { // multiViewport enabled
4605 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004606 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004607 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4608 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4609 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4610 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004611 }
4612 }
4613
Jeff Bolz3e71f782018-08-29 23:15:45 -05004614 if (pExclusiveScissors) {
4615 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4616 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4617
4618 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004619 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4620 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4621 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004622 }
4623
4624 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004625 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4626 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4627 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004628 }
4629
4630 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4631 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004632 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4633 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4634 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4635 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004636 }
4637
4638 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4639 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004640 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4641 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4642 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4643 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004644 }
4645 }
4646 }
4647
4648 return skip;
4649}
4650
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004651bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4652 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004653 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004654 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004655 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4656 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4657 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4658 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4659 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4660 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004661 }
4662
4663 return skip;
4664}
4665
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004666bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4667 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004668 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004669 bool skip = false;
4670
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004671 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004672 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004673 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004674 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4675 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4676 ") is not 0.",
4677 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004678 }
4679 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004680 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004681 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4682 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4683 ") is not 1.",
4684 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004685 }
4686 }
4687
Jeff Bolz9af91c52018-09-01 21:53:57 -05004688 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004689 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004690 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4691 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4692 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4693 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004694 }
4695
4696 return skip;
4697}
4698
Jeff Bolz5c801d12019-10-09 10:38:45 -05004699bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4700 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4701 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004702 bool skip = false;
4703
Dave Houlton142c4cb2018-10-17 15:04:41 -06004704 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004705 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4706 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4707 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004708 }
4709
4710 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004711 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004712 }
4713
4714 return skip;
4715}
4716
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004717bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004718 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004719 bool skip = false;
4720
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004721 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004722 skip |= LogError(
4723 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004724 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4725 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004726 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004727 }
4728
4729 return skip;
4730}
4731
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004732bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4733 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004734 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004735 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004736 static const int condition_multiples = 0b0011;
4737 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004738 skip |= LogError(
4739 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004740 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004741 }
Lockee1c22882019-06-10 16:02:54 -06004742 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004743 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4744 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4745 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4746 stride);
Lockee1c22882019-06-10 16:02:54 -06004747 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004748 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004749 skip |= LogError(
4750 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4751 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004752 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004753 if (drawCount > device_limits.maxDrawIndirectCount) {
4754 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004755 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4756 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004757 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004758 return skip;
4759}
4760
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004761bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4762 VkDeviceSize offset, VkBuffer countBuffer,
4763 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004764 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004765 bool skip = false;
4766
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004767 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004768 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4769 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4770 "), is not a multiple of 4.",
4771 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004772 }
4773
4774 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004775 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4776 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4777 "), is not a multiple of 4.",
4778 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004779 }
4780
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004781 return skip;
4782}
4783
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004784bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004785 const VkAllocationCallbacks *pAllocator,
4786 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004787 bool skip = false;
4788
4789 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4790 if (pCreateInfo != nullptr) {
4791 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4792 // VkQueryPipelineStatisticFlagBits values
4793 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4794 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004795 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4796 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4797 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4798 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004799 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004800 if (pCreateInfo->queryCount == 0) {
4801 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4802 "vkCreateQueryPool(): queryCount must be greater than zero.");
4803 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004804 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004805 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004806}
4807
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004808bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4809 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004810 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004811 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4812 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004813}
4814
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004815void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004816 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4817 VkResult result) {
4818 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004819 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004820}
4821
Mike Schuchardt2df08912020-12-15 16:28:09 -08004822void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004823 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4824 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004825 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004826 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004827 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004828}
4829
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004830void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4831 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004832 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004833 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004834 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004835}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004836
Tony-LunarG3c287f62020-12-17 12:39:49 -07004837void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004838 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004839 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4840 auto lock = cb_write_lock();
4841 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004842 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004843 }
4844 }
4845}
4846
4847void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004848 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004849 auto lock = cb_write_lock();
4850 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4851 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4852 }
4853}
4854
4855void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004856 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004857 auto lock = cb_write_lock();
4858 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4859 if (item->second == commandPool) {
4860 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004861 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004862 ++item;
4863 }
4864 }
4865}
4866
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004867bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004868 const VkAllocationCallbacks *pAllocator,
4869 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004870 bool skip = false;
4871
4872 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004873 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004874 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004875 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4876 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004877 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004878
4879 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004880 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004881 if (flags_info) {
4882 flags = flags_info->flags;
4883 }
4884
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004885 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004886 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004887 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004888 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4889 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004890 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004891 }
4892
4893#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004894 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004895#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004896 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4897 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004898#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004899 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004900#endif
4901
4902 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004903 skip |= LogError(
4904 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004905 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4906 }
4907 if (
4908#ifdef VK_USE_PLATFORM_WIN32_KHR
4909 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4910#endif
4911 (import_memory_fd && import_memory_fd->handleType) ||
4912#ifdef VK_USE_PLATFORM_ANDROID_KHR
4913 (import_memory_ahb && import_memory_ahb->buffer) ||
4914#endif
4915 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004916 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4917 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004918 }
4919 }
4920
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02004921 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
4922 if (export_memory) {
4923 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
4924 if (export_memory_nv) {
4925 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4926 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4927 "VkExportMemoryAllocateInfoNV");
4928 }
4929#ifdef VK_USE_PLATFORM_WIN32_KHR
4930 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
4931 if (export_memory_win32_nv) {
4932 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4933 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4934 "VkExportMemoryWin32HandleInfoNV");
4935 }
4936#endif
4937 }
4938
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004939 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004940 VkBool32 capture_replay = false;
4941 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004942 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004943 if (vulkan_12_features) {
4944 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4945 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4946 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004947 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004948 if (bda_features) {
4949 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4950 buffer_device_address = bda_features->bufferDeviceAddress;
4951 }
4952 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004953 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004954 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004955 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004956 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004957 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004958 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004959 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004960 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004961 }
4962 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004963 }
4964 return skip;
4965}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004966
Jason Macnak192fa0e2019-07-26 15:07:16 -07004967bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004968 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004969 bool skip = false;
4970
4971 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4972 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4973 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004974 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004975 } else {
4976 uint32_t vertex_component_size = 0;
4977 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4978 vertex_component_size = 4;
4979 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4980 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4981 vertex_component_size = 2;
4982 }
4983 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004984 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004985 }
4986 }
4987
4988 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4989 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004990 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004991 } else {
4992 uint32_t index_element_size = 0;
4993 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4994 index_element_size = 4;
4995 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4996 index_element_size = 2;
4997 }
4998 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004999 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005000 }
5001 }
5002 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5003 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005004 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005005 }
5006 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005007 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005008 }
5009 }
5010
5011 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005012 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005013 }
5014
5015 return skip;
5016}
5017
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005018bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5019 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005020 bool skip = false;
5021
5022 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005023 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005024 }
5025 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005026 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005027 }
5028
5029 return skip;
5030}
5031
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005032bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5033 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005034 bool skip = false;
5035 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005036 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005037 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005038 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005039 }
5040 return skip;
5041}
5042
5043bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005044 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005045 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005046 bool skip = false;
5047 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005048 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5049 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5050 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005051 }
5052 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005053 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5054 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5055 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005056 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005057 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5058 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5059 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5060 }
Jason Macnak5c954952019-07-09 15:46:12 -07005061 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5062 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005063 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5064 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5065 "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 -07005066 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005067 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005068 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005069 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5070 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005071 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5072 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005073 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005074 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005075 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5076 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5077 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005078 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005079 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005080 uint64_t total_triangle_count = 0;
5081 for (uint32_t i = 0; i < info.geometryCount; i++) {
5082 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005083
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005084 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005085
Jason Macnak5c954952019-07-09 15:46:12 -07005086 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5087 continue;
5088 }
5089 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5090 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005091 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005092 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5093 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5094 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005095 }
5096 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005097 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5098 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5099 for (uint32_t i = 1; i < info.geometryCount; i++) {
5100 const VkGeometryNV &geometry = info.pGeometries[i];
5101 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005102 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005103 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
5104 "info.pGeometries[0].geometryType.",
5105 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005106 }
5107 }
5108 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005109 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5110 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5111 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5112 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5113 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5114 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5115 }
5116 }
5117 skip |=
5118 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005119 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005120 return skip;
5121}
5122
Ricardo Garciaa4935972019-02-21 17:43:18 +01005123bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5124 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005125 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005126 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005127 if (pCreateInfo) {
5128 if ((pCreateInfo->compactedSize != 0) &&
5129 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005130 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5131 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5132 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5133 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005134 }
Jason Macnak5c954952019-07-09 15:46:12 -07005135
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005136 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005137 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005138 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005139 return skip;
5140}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005141
Jeff Bolz5c801d12019-10-09 10:38:45 -05005142bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5143 const VkAccelerationStructureInfoNV *pInfo,
5144 VkBuffer instanceData, VkDeviceSize instanceOffset,
5145 VkBool32 update, VkAccelerationStructureNV dst,
5146 VkAccelerationStructureNV src, VkBuffer scratch,
5147 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005148 bool skip = false;
5149
5150 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005151 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005152 }
5153
5154 return skip;
5155}
5156
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005157bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5158 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5159 VkAccelerationStructureKHR *pAccelerationStructure) const {
5160 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005161 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005162 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005163 if (!acceleration_structure_features ||
5164 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5165 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5166 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5167 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005168 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005169 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5170 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005171 (acceleration_structure_features &&
5172 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005173 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005174 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5175 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5176 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5177 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005178 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005179 if (pCreateInfo->deviceAddress &&
5180 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5181 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5182 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5183 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5184 }
5185 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5186 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005187 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005188 }
sourav parmar83c31b12020-05-06 12:30:54 -07005189 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005190 return skip;
5191}
5192
Jason Macnak5c954952019-07-09 15:46:12 -07005193bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5194 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005195 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005196 bool skip = false;
5197 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005198 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5199 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005200 }
5201 return skip;
5202}
5203
sourav parmarcd5fb182020-07-17 12:58:44 -07005204bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5205 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5206 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5207 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005208 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005209 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005210 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005211 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005212 }
5213 return skip;
5214}
5215
Peter Chen85366392019-05-14 15:20:11 -04005216bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5217 uint32_t createInfoCount,
5218 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5219 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005220 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005221 bool skip = false;
5222
5223 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005224 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5225 std::stringstream msg;
5226 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5227 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5228 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005229 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005230 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005231 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005232 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5233 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5234 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5235 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005236 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005237
5238 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005239 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005240 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5241 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5242 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5243 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5244 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5245 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5246 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5247 }
5248 }
5249
sourav parmarf4a78252020-04-10 13:04:21 -07005250 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5251 skip |=
5252 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5253 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5254 }
5255 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5256 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5257 skip |=
5258 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5259 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5260 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5261 }
5262 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5263 if (pCreateInfos[i].basePipelineIndex != -1) {
5264 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5265 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5266 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5267 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5268 "and pCreateInfos->basePipelineIndex is not -1.");
5269 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005270 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005271 skip |=
5272 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5273 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5274 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5275 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5276 "that element.");
5277 }
sourav parmarf4a78252020-04-10 13:04:21 -07005278 }
5279 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005280 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005281 skip |=
5282 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5283 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5284 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5285 "commands pCreateInfos parameter.");
5286 }
5287 } else {
5288 if (pCreateInfos[i].basePipelineIndex != -1) {
5289 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5290 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5291 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5292 }
5293 }
5294 }
5295 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5296 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5297 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5298 }
5299 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5300 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5301 "vkCreateRayTracingPipelinesNV: flags must not include "
5302 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5303 }
5304 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5305 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5306 "vkCreateRayTracingPipelinesNV: flags must not include "
5307 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5308 }
5309 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5310 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5311 "vkCreateRayTracingPipelinesNV: flags must not include "
5312 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5313 }
5314 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5315 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5316 "vkCreateRayTracingPipelinesNV: flags must not include "
5317 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5318 }
5319 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5320 skip |= LogError(
5321 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5322 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5323 }
5324 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5325 skip |= LogError(
5326 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5327 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5328 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005329 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5330 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5331 "vkCreateRayTracingPipelinesNV: flags must not include "
5332 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5333 }
5334 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5335 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5336 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5337 }
Peter Chen85366392019-05-14 15:20:11 -04005338 }
5339
5340 return skip;
5341}
5342
sourav parmarcd5fb182020-07-17 12:58:44 -07005343bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5344 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5345 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005346 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005347 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005348 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5349 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5350 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005351 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005352 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005353 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5354 std::stringstream msg;
5355 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5356 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5357 &pCreateInfos[i].pStages[i]);
5358 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005359 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5360 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5361 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5362 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5363 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5364 }
5365 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5366 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5367 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5368 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5369 }
5370 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005371 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005372 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5373 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005374 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5375 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5376 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005377 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5378 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5379 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005380 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005381 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005382 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5383 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5384 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5385 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005386 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005387 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5388 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5389 }
5390 }
sourav parmarf4a78252020-04-10 13:04:21 -07005391 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005392 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5393 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005394 }
5395 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005396 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005397 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005398 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5399 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005400 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005401 }
5402 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5403 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5404 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005405 }
5406 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5407 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5408 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5409 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5410 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5411 skip |= LogError(
5412 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005413 "vkCreateRayTracingPipelinesKHR: If flags includes "
5414 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005415 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5416 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5417 "must not be VK_SHADER_UNUSED_KHR");
5418 }
5419 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5420 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5421 skip |= LogError(
5422 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005423 "vkCreateRayTracingPipelinesKHR: If flags includes "
5424 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005425 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5426 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5427 "element must not be VK_SHADER_UNUSED_KHR");
5428 }
5429 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005430 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5431 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5432 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5433 skip |= LogError(
5434 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5435 "vkCreateRayTracingPipelinesKHR: If "
5436 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5437 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5438 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5439 }
5440 }
sourav parmarf4a78252020-04-10 13:04:21 -07005441 }
5442 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5443 if (pCreateInfos[i].basePipelineIndex != -1) {
5444 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5445 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005446 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005447 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5448 "and pCreateInfos->basePipelineIndex is not -1.");
5449 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005450 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005451 skip |=
5452 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5453 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5454 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5455 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5456 "element.");
5457 }
sourav parmarf4a78252020-04-10 13:04:21 -07005458 }
5459 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005460 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005461 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005462 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005463 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5464 "commands pCreateInfos parameter %d.",
5465 pCreateInfos[i].basePipelineIndex, createInfoCount);
5466 }
5467 } else {
5468 if (pCreateInfos[i].basePipelineIndex != -1) {
5469 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005470 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005471 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5472 }
5473 }
5474 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005475 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5476 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5477 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5478 "vkCreateRayTracingPipelinesKHR: If flags includes "
5479 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5480 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005481 }
5482 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5483 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5484 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5485 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5486 "pLibraryInfo and pLibraryInterface must be NULL.");
5487 }
5488 if (pCreateInfos[i].pLibraryInfo) {
5489 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5490 if (pCreateInfos[i].stageCount == 0) {
5491 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5492 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5493 "stageCount must not be 0.");
5494 }
5495 if (pCreateInfos[i].groupCount == 0) {
5496 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5497 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5498 "groupCount must not be 0.");
5499 }
5500 } else {
5501 if (pCreateInfos[i].pLibraryInterface == NULL) {
5502 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5503 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5504 "is greater than 0, its "
5505 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005506 }
5507 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005508 }
5509 if (pCreateInfos[i].pLibraryInterface) {
5510 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5511 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5512 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5513 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5514 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5515 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005516 }
5517 if (deferredOperation != VK_NULL_HANDLE) {
5518 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5519 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5520 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5521 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005522 }
5523 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005524 }
5525
5526 return skip;
5527}
5528
Mike Schuchardt21638df2019-03-16 10:52:02 -07005529#ifdef VK_USE_PLATFORM_WIN32_KHR
5530bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5531 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005532 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005533 bool skip = false;
5534 if (!device_extensions.vk_khr_swapchain)
5535 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005536 if (!device_extensions.vk_khr_get_surface_capabilities2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005537 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5538 if (!device_extensions.vk_khr_surface)
5539 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005540 if (!device_extensions.vk_khr_get_physical_device_properties2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005541 skip |=
5542 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5543 if (!device_extensions.vk_ext_full_screen_exclusive)
5544 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5545 skip |= validate_struct_type(
5546 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5547 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5548 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5549 if (pSurfaceInfo != NULL) {
5550 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5551 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5552 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5553
5554 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5555 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5556 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5557 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005558 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5559 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005560
5561 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5562 }
5563 return skip;
5564}
5565#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005566
5567bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5568 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005569 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005570 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5571 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005572 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005573 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5574 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5575 }
5576 return skip;
5577}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005578
5579bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005580 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005581 bool skip = false;
5582
5583 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005584 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5585 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005586 }
5587
5588 return skip;
5589}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005590
5591bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005592 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005593 bool skip = false;
5594
5595 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005596 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5597 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005598 }
5599
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005600 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005601 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005602 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5603 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005604 }
5605
5606 return skip;
5607}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005608
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005609bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5610 uint32_t bindingCount, const VkBuffer *pBuffers,
5611 const VkDeviceSize *pOffsets) const {
5612 bool skip = false;
5613 if (firstBinding > device_limits.maxVertexInputBindings) {
5614 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5615 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5616 device_limits.maxVertexInputBindings);
5617 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5618 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5619 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5620 "maxVertexInputBindings (%u)",
5621 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5622 }
5623
Jeff Bolz165818a2020-05-08 11:19:03 -05005624 for (uint32_t i = 0; i < bindingCount; ++i) {
5625 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005626 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005627 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5628 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5629 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5630 } else {
5631 if (pOffsets[i] != 0) {
5632 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5633 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5634 }
5635 }
5636 }
5637 }
5638
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005639 return skip;
5640}
5641
Mark Lobodzinski84988402019-09-11 15:27:30 -06005642bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005643 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005644 bool skip = false;
5645 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005646 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5647 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005648 }
5649 return skip;
5650}
5651
5652bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005653 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005654 bool skip = false;
5655 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005656 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5657 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005658 }
5659 return skip;
5660}
Petr Kraus3d720392019-11-13 02:52:39 +01005661
5662bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5663 VkSemaphore semaphore, VkFence fence,
5664 uint32_t *pImageIndex) const {
5665 bool skip = false;
5666
5667 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005668 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5669 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005670 }
5671
5672 return skip;
5673}
5674
5675bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5676 uint32_t *pImageIndex) const {
5677 bool skip = false;
5678
5679 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005680 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5681 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005682 }
5683
5684 return skip;
5685}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005686
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005687bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5688 uint32_t firstBinding, uint32_t bindingCount,
5689 const VkBuffer *pBuffers,
5690 const VkDeviceSize *pOffsets,
5691 const VkDeviceSize *pSizes) const {
5692 bool skip = false;
5693
5694 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5695 for (uint32_t i = 0; i < bindingCount; ++i) {
5696 if (pOffsets[i] & 3) {
5697 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5698 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5699 }
5700 }
5701
5702 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5703 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5704 "%s: The firstBinding(%" PRIu32
5705 ") index is greater than or equal to "
5706 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5707 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5708 }
5709
5710 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5711 skip |=
5712 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5713 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5714 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5715 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5716 }
5717
5718 for (uint32_t i = 0; i < bindingCount; ++i) {
5719 // pSizes is optional and may be nullptr.
5720 if (pSizes != nullptr) {
5721 if (pSizes[i] != VK_WHOLE_SIZE &&
5722 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5723 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5724 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5725 ") is not VK_WHOLE_SIZE and is greater than "
5726 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5727 cmd_name, i, pSizes[i]);
5728 }
5729 }
5730 }
5731
5732 return skip;
5733}
5734
5735bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5736 uint32_t firstCounterBuffer,
5737 uint32_t counterBufferCount,
5738 const VkBuffer *pCounterBuffers,
5739 const VkDeviceSize *pCounterBufferOffsets) const {
5740 bool skip = false;
5741
5742 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5743 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5744 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5745 "%s: The firstCounterBuffer(%" PRIu32
5746 ") index is greater than or equal to "
5747 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5748 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5749 }
5750
5751 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5752 skip |=
5753 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5754 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5755 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5756 cmd_name, firstCounterBuffer, counterBufferCount,
5757 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5758 }
5759
5760 return skip;
5761}
5762
5763bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5764 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5765 const VkBuffer *pCounterBuffers,
5766 const VkDeviceSize *pCounterBufferOffsets) const {
5767 bool skip = false;
5768
5769 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5770 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5771 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5772 "%s: The firstCounterBuffer(%" PRIu32
5773 ") index is greater than or equal to "
5774 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5775 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5776 }
5777
5778 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5779 skip |=
5780 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5781 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5782 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5783 cmd_name, firstCounterBuffer, counterBufferCount,
5784 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5785 }
5786
5787 return skip;
5788}
5789
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005790bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5791 uint32_t firstInstance, VkBuffer counterBuffer,
5792 VkDeviceSize counterBufferOffset,
5793 uint32_t counterOffset, uint32_t vertexStride) const {
5794 bool skip = false;
5795
5796 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005797 skip |= LogError(
5798 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005799 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5800 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5801 }
5802
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005803 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005804 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005805 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005806 }
5807
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005808 return skip;
5809}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005810
5811bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5812 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5813 const VkAllocationCallbacks *pAllocator,
5814 VkSamplerYcbcrConversion *pYcbcrConversion,
5815 const char *apiName) const {
5816 bool skip = false;
5817
5818 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005819 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005820 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005821 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005822 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5823 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005824 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005825 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005826 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005827
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005828#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005829 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005830 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005831#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005832 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005833#endif
5834
sfricke-samsung1a72f942020-07-25 12:09:18 -07005835 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005836
5837 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005838 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005839 const VkComponentMapping components = pCreateInfo->components;
5840 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5841 if (FormatIsXChromaSubsampled(format) == true) {
5842 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5843 skip |=
5844 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005845 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5846 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005847 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005848 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005849
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005850 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5851 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5852 skip |= LogError(
5853 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5854 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5855 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5856 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5857 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005858
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005859 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5860 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5861 skip |=
5862 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005863 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5864 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005865 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005866 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005867
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005868 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5869 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5870 skip |=
5871 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005872 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5873 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005874 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005875 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005876
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005877 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005878 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5879 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5880 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005881 skip |=
5882 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005883 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5884 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005885 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5886 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005887 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005888 }
5889
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005890 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5891 // Checks same VU multiple ways in order to give a more useful error message
5892 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5893 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5894 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5895 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5896 skip |= LogError(
5897 device, vuid,
5898 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5899 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5900 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5901 string_VkComponentSwizzle(components.b));
5902 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005903
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005904 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5905 // 4 channel format = no issue
5906 // 3 = no [a]
5907 // 2 = no [b,a]
5908 // 1 = no [g,b,a]
5909 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5910 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5911
5912 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5913 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5914 skip |= LogError(device, vuid,
5915 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5916 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5917 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5918 string_VkComponentSwizzle(components.b));
5919 } else if ((channels < 3) &&
5920 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5921 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5922 skip |= LogError(device, vuid,
5923 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5924 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5925 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5926 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5927 string_VkComponentSwizzle(components.b));
5928 } else if ((channels < 2) &&
5929 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5930 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5931 skip |= LogError(device, vuid,
5932 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5933 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5934 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5935 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5936 string_VkComponentSwizzle(components.b));
5937 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005938 }
5939 }
5940
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005941 return skip;
5942}
5943
5944bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5945 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5946 const VkAllocationCallbacks *pAllocator,
5947 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5948 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5949 "vkCreateSamplerYcbcrConversion");
5950}
5951
5952bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5953 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5954 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5955 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5956 "vkCreateSamplerYcbcrConversionKHR");
5957}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005958
5959bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5960 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5961 bool skip = false;
5962 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5963 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5964
5965 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005966 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5967 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5968 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5969 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5970 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005971 }
5972 return skip;
5973}
sourav parmara96ab1a2020-04-25 16:28:23 -07005974
5975bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005976 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005977 bool skip = false;
5978 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5979 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5980 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5981 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005982 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005983 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5984 skip |= LogError(
5985 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5986 "vkCopyAccelerationStructureToMemoryKHR: The "
5987 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5988 }
5989 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5990 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5991 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5992 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5993 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5994 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005995 return skip;
5996}
5997
5998bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5999 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6000 bool skip = false;
6001 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6002 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6003 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6004 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6005 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006006 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6007 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006008 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006009 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006010 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006011 return skip;
6012}
6013
6014bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6015 const char *api_name) const {
6016 bool skip = false;
6017 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6018 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6019 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6020 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6021 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6022 api_name);
6023 }
6024 return skip;
6025}
6026
6027bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006028 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006029 bool skip = false;
6030 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006031 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006032 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006033 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006034 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6035 "vkCopyAccelerationStructureKHR: The "
6036 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006037 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006038 return skip;
6039}
6040
6041bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6042 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6043 bool skip = false;
6044 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6045 return skip;
6046}
6047
6048bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006049 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006050 bool skip = false;
6051 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006052 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006053 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6054 }
6055 return skip;
6056}
6057
6058bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006059 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006060 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006061 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006062 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006063 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6064 skip |= LogError(
6065 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6066 "vkCopyMemoryToAccelerationStructureKHR: The "
6067 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006068 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006069 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6070 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006071 return skip;
6072}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006073
sourav parmara96ab1a2020-04-25 16:28:23 -07006074bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6075 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6076 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006077 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006078 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6079 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006080 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006081 pInfo->src.deviceAddress);
6082 }
sourav parmar83c31b12020-05-06 12:30:54 -07006083 return skip;
6084}
6085bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6086 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6087 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6088 bool skip = false;
6089 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6090 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6091 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6092 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6093 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6094 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6095 }
6096 return skip;
6097}
6098bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6099 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6100 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6101 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006102 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006103 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6104 skip |= LogError(
6105 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6106 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6107 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6108 }
sourav parmar83c31b12020-05-06 12:30:54 -07006109 if (dataSize < accelerationStructureCount * stride) {
6110 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6111 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
6112 "accelerationStructureCount (%d) *stride(%zu).",
6113 dataSize, accelerationStructureCount, stride);
6114 }
6115 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6116 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6117 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6118 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6119 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6120 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6121 }
6122 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6123 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6124 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6125 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6126 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6127 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6128 stride);
6129 }
6130 }
6131 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6132 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6133 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6134 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6135 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6136 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6137 stride);
6138 }
6139 }
sourav parmar83c31b12020-05-06 12:30:54 -07006140 return skip;
6141}
6142bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6143 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6144 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006145 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006146 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6147 skip |= LogError(
6148 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6149 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6150 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006151 }
6152 return skip;
6153}
6154
6155bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006156 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6157 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6158 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6159 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006160 uint32_t width, uint32_t height, uint32_t depth) const {
6161 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006162 // RayGen
6163 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6164 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6165 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006166 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006167 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6168 0) {
6169 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6170 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6171 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6172 }
6173 // Callable
6174 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6175 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6176 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6177 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006178 }
6179 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6180 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6181 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006182 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6183 }
6184 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6185 0) {
6186 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6187 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6188 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006189 }
6190 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006191 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6192 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6193 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6194 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006195 }
6196 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6197 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006198 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6199 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006200 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006201 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6202 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6203 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6204 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6205 }
sourav parmar83c31b12020-05-06 12:30:54 -07006206 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006207 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6208 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6209 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6210 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006211 }
6212 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6213 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6214 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006215 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6216 }
6217 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6218 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6219 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6220 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6221 }
6222 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6223 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6224 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6225 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6226 }
6227 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6228 skip |=
6229 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6230 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6231 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006232 }
6233
sourav parmarcd5fb182020-07-17 12:58:44 -07006234 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6235 skip |=
6236 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6237 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6238 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6239 }
6240
6241 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6242 skip |=
6243 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6244 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6245 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006246 }
6247 return skip;
6248}
6249
sourav parmarcd5fb182020-07-17 12:58:44 -07006250bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6251 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6252 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6253 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006254 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006255 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006256 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6257 skip |= LogError(
6258 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6259 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6260 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006261 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006262 // RayGen
6263 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6264 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6265 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006266 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006267 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6268 0) {
6269 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6270 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6271 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6272 }
6273 // Callabe
6274 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6275 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6276 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6277 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006278 }
6279 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6280 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006281 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6282 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6283 }
6284 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6285 0) {
6286 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6287 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6288 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006289 }
6290 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006291 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6292 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6293 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6294 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006295 }
6296 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6297 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006298 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6299 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006300 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006301 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6302 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6303 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6304 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6305 }
sourav parmar83c31b12020-05-06 12:30:54 -07006306 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006307 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6308 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6309 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6310 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006311 }
6312 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6313 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006314 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6315 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6316 }
6317 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6318 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6319 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6320 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006321 }
6322
sourav parmarcd5fb182020-07-17 12:58:44 -07006323 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6324 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6325 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006326 }
6327 return skip;
6328}
6329bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6330 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6331 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6332 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6333 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6334 uint32_t width, uint32_t height, uint32_t depth) const {
6335 bool skip = false;
6336 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6337 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6338 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6339 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6340 }
6341 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6342 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6343 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6344 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6345 }
6346 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6347 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6348 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6349 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6350 }
6351
6352 // hitShader
6353 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6354 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6355 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6356 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6357 }
6358 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6359 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6360 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6361 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6362 }
6363 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6364 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6365 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6366 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6367 }
6368
6369 // missShader
6370 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6371 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6372 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6373 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6374 }
6375 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6376 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6377 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6378 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6379 }
6380 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6381 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6382 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6383 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6384 }
6385
6386 // raygenShader
6387 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6388 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6389 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006390 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6391 }
6392 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6393 skip |=
6394 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6395 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6396 }
6397 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6398 skip |=
6399 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6400 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6401 }
6402 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6403 skip |=
6404 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6405 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006406 }
6407 return skip;
6408}
6409
sourav parmar83c31b12020-05-06 12:30:54 -07006410bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006411 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6412 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006413 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006414 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6415 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006416 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6417 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006418 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006419 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6420 }
6421 return skip;
6422}
6423
Piers Daniell39842ee2020-07-10 16:42:33 -06006424bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6425 const VkViewport *pViewports) const {
6426 bool skip = false;
6427
6428 if (!physical_device_features.multiViewport) {
6429 if (viewportCount != 1) {
6430 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6431 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6432 ") is not 1.",
6433 viewportCount);
6434 }
6435 } else { // multiViewport enabled
6436 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6437 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6438 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6439 ") must "
6440 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6441 viewportCount, device_limits.maxViewports);
6442 }
6443 }
6444
6445 if (pViewports) {
6446 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6447 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6448 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6449 skip |= manual_PreCallValidateViewport(
6450 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6451 }
6452 }
6453
6454 return skip;
6455}
6456
6457bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6458 const VkRect2D *pScissors) const {
6459 bool skip = false;
6460
6461 if (!physical_device_features.multiViewport) {
6462 if (scissorCount != 1) {
6463 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6464 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6465 ") must "
6466 "be 1 when the multiViewport feature is disabled.",
6467 scissorCount);
6468 }
6469 } else { // multiViewport enabled
6470 if (scissorCount == 0) {
6471 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6472 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6473 ") must "
6474 "be great than zero.",
6475 scissorCount);
6476 } else if (scissorCount > device_limits.maxViewports) {
6477 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6478 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6479 ") must "
6480 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6481 scissorCount, device_limits.maxViewports);
6482 }
6483 }
6484
6485 if (pScissors) {
6486 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6487 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6488
6489 if (scissor.offset.x < 0) {
6490 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6491 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6492 scissor.offset.x);
6493 }
6494
6495 if (scissor.offset.y < 0) {
6496 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6497 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6498 scissor.offset.y);
6499 }
6500
6501 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6502 if (x_sum > INT32_MAX) {
6503 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6504 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6505 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6506 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6507 }
6508
6509 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6510 if (y_sum > INT32_MAX) {
6511 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6512 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6513 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6514 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6515 }
6516 }
6517 }
6518
6519 return skip;
6520}
6521
6522bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6523 uint32_t bindingCount, const VkBuffer *pBuffers,
6524 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6525 const VkDeviceSize *pStrides) const {
6526 bool skip = false;
6527 if (firstBinding >= device_limits.maxVertexInputBindings) {
6528 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6529 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6530 firstBinding, device_limits.maxVertexInputBindings);
6531 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6532 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6533 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6534 "maxVertexInputBindings (%u)",
6535 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6536 }
6537
6538 for (uint32_t i = 0; i < bindingCount; ++i) {
6539 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006540 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006541 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6542 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6543 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6544 } else {
6545 if (pOffsets[i] != 0) {
6546 skip |=
6547 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6548 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6549 }
6550 }
6551 }
6552 if (pStrides) {
6553 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6554 skip |=
6555 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006556 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i,
Piers Daniell39842ee2020-07-10 16:42:33 -06006557 pStrides[i], device_limits.maxVertexInputBindingStride);
6558 }
6559 }
6560 }
6561
6562 return skip;
6563}
sourav parmarcd5fb182020-07-17 12:58:44 -07006564
6565bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6566 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6567 bool skip = false;
6568 for (uint32_t i = 0; i < infoCount; ++i) {
6569 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6570 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6571 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6572 }
6573 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6574 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6575 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6576 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6577 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6578 api_name);
6579 }
6580 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6581 skip |=
6582 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6583 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6584 }
6585 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6586 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6587 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6588 }
6589 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6590 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6591 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6592 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6593 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6594 api_name);
6595 }
6596 if (pInfos[i].pGeometries) {
6597 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6598 skip |= validate_ranged_enum(
6599 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6600 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6601 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6602 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006603 skip |= validate_struct_type(
6604 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6605 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6606 &(pInfos[i].pGeometries[j].geometry.triangles),
6607 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6608 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6609 skip |= validate_struct_pnext(
6610 api_name,
6611 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6612 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6613 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6614 skip |=
6615 validate_ranged_enum(api_name,
6616 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6617 ParameterName::IndexVector{i, j}),
6618 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6619 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6620 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6621 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6622 &pInfos[i].pGeometries[j].geometry.triangles,
6623 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6624 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6625 skip |= validate_ranged_enum(
6626 api_name,
6627 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6628 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6629 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6630
6631 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6632 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6633 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6634 }
6635 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6636 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6637 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6638 skip |=
6639 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6640 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6641 api_name);
6642 }
6643 }
6644 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6645 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6646 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6647 &pInfos[i].pGeometries[j].geometry.instances,
6648 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6649 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6650 skip |= validate_struct_type(
6651 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6652 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6653 &(pInfos[i].pGeometries[j].geometry.instances),
6654 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6655 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6656 skip |= validate_struct_pnext(
6657 api_name,
6658 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6659 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6660 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6661
6662 skip |= validate_bool32(api_name,
6663 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6664 ParameterName::IndexVector{i, j}),
6665 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6666 }
6667 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6668 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6669 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6670 &pInfos[i].pGeometries[j].geometry.aabbs,
6671 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6672 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6673 skip |= validate_struct_type(
6674 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6675 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6676 &(pInfos[i].pGeometries[j].geometry.aabbs),
6677 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6678 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6679 skip |= validate_struct_pnext(
6680 api_name,
6681 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6682 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6683 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6684 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6685 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6686 "(%s):stride must be less than or equal to 2^32-1", api_name);
6687 }
6688 }
6689 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6690 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6691 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6692 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6693 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6694 api_name);
6695 }
6696 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6697 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6698 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6699 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6700 "of elements of"
6701 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6702 api_name);
6703 }
6704 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6705 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6706 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6707 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6708 api_name);
6709 }
6710 }
6711 }
6712 }
6713 if (pInfos[i].ppGeometries != NULL) {
6714 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6715 skip |= validate_ranged_enum(
6716 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6717 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6718 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6719 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006720 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6721 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6722 &pInfos[i].ppGeometries[j]->geometry.triangles,
6723 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6724 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6725 skip |= validate_struct_type(
6726 api_name,
6727 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6728 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6729 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6730 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6731 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6732 skip |= validate_struct_pnext(
6733 api_name,
6734 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6735 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6736 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6737 skip |= validate_ranged_enum(api_name,
6738 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6739 ParameterName::IndexVector{i, j}),
6740 "VkFormat", AllVkFormatEnums,
6741 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6742 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6743 skip |= validate_ranged_enum(api_name,
6744 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6745 ParameterName::IndexVector{i, j}),
6746 "VkIndexType", AllVkIndexTypeEnums,
6747 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6748 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6749 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6750 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6751 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6752 }
6753 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6754 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6755 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6756 skip |=
6757 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6758 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6759 api_name);
6760 }
6761 }
6762 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6763 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6764 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6765 &pInfos[i].ppGeometries[j]->geometry.instances,
6766 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6767 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6768 skip |= validate_struct_type(
6769 api_name,
6770 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6771 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6772 &(pInfos[i].ppGeometries[j]->geometry.instances),
6773 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6774 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6775 skip |= validate_struct_pnext(
6776 api_name,
6777 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6778 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6779 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6780 skip |= validate_bool32(api_name,
6781 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6782 ParameterName::IndexVector{i, j}),
6783 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6784 }
6785 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6786 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6787 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6788 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6789 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6790 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6791 skip |= validate_struct_type(
6792 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6793 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6794 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6795 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6796 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6797 skip |= validate_struct_pnext(
6798 api_name,
6799 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6800 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6801 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6802 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6803 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6804 "(%s):stride must be less than or equal to 2^32-1", api_name);
6805 }
6806 }
6807 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6808 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6809 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6810 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6811 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6812 api_name);
6813 }
6814 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6815 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6816 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6817 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6818 "of elements of"
6819 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6820 api_name);
6821 }
6822 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6823 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6824 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6825 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6826 api_name);
6827 }
6828 }
6829 }
6830 }
6831 }
6832 return skip;
6833}
6834bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6835 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6836 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6837 bool skip = false;
6838 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6839 for (uint32_t i = 0; i < infoCount; ++i) {
6840 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6841 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6842 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6843 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6844 "scratchData.deviceAddress member must be a multiple of "
6845 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6846 }
6847 for (uint32_t k = 0; k < infoCount; ++k) {
6848 if (i == k) continue;
6849 bool found = false;
6850 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6851 skip |= LogError(
6852 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6853 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6854 "not be "
6855 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6856 i, k);
6857 found = true;
6858 }
6859 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6860 skip |= LogError(
6861 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6862 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6863 "not be "
6864 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6865 i, k);
6866 found = true;
6867 }
6868 if (found) break;
6869 }
6870 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6871 if (pInfos[i].pGeometries) {
6872 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6873 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6874 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6875 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6876 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6877 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6878 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6879 }
6880 } else {
6881 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6882 skip |=
6883 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6884 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6885 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6886 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6887 }
6888 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006889 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006890 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6891 skip |= LogError(
6892 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6893 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6894 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6895 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006896 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6897 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006898 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6899 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6900 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6901 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6902 }
6903 }
6904 } else if (pInfos[i].ppGeometries) {
6905 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6906 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6907 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6908 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6909 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6910 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6911 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6912 }
6913 } else {
6914 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6915 skip |=
6916 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6917 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6918 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6919 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6920 }
6921 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006922 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006923 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6924 skip |= LogError(
6925 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6926 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6927 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6928 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006929 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6930 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006931 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6932 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6933 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6934 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6935 }
6936 }
6937 }
6938 }
6939 }
6940 return skip;
6941}
6942
6943bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6944 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6945 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6946 const uint32_t *const *ppMaxPrimitiveCounts) const {
6947 bool skip = false;
6948 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6949 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006950 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006951 if (!ray_tracing_acceleration_structure_features ||
6952 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6953 skip |= LogError(
6954 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6955 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6956 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6957 }
6958 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006959 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6960 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6961 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6962 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6963 "scratchData.deviceAddress member must be a multiple of "
6964 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6965 }
6966 for (uint32_t k = 0; k < infoCount; ++k) {
6967 if (i == k) continue;
6968 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6969 skip |=
6970 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6971 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6972 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6973 "any other element [%d) of pInfos.",
6974 i, k);
6975 break;
6976 }
6977 }
6978 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6979 if (pInfos[i].pGeometries) {
6980 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6981 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6982 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6983 skip |= LogError(
6984 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6985 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6986 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6987 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6988 }
6989 } else {
6990 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6991 skip |= LogError(
6992 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6993 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6994 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6995 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6996 }
6997 }
6998 }
6999 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7000 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7001 skip |= LogError(
7002 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7003 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7004 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7005 }
7006 }
7007 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7008 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7009 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7010 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7011 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7012 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7013 }
7014 }
7015 } else if (pInfos[i].ppGeometries) {
7016 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7017 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7018 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7019 skip |= LogError(
7020 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7021 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7022 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7023 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7024 }
7025 } else {
7026 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7027 skip |= LogError(
7028 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7029 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7030 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7031 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7032 }
7033 }
7034 }
7035 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7036 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7037 skip |= LogError(
7038 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7039 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7040 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7041 }
7042 }
7043 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7044 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7045 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7046 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7047 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7048 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7049 }
7050 }
7051 }
7052 }
7053 }
7054 return skip;
7055}
7056
7057bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7058 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7059 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7060 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7061 bool skip = false;
7062 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7063 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007064 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007065 if (!ray_tracing_acceleration_structure_features ||
7066 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7067 skip |=
7068 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7069 "vkBuildAccelerationStructuresKHR: The "
7070 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7071 }
7072 for (uint32_t i = 0; i < infoCount; ++i) {
7073 for (uint32_t j = 0; j < infoCount; ++j) {
7074 if (i == j) continue;
7075 bool found = false;
7076 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7077 skip |= LogError(
7078 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7079 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
7080 "not be "
7081 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7082 i, j);
7083 found = true;
7084 }
7085 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7086 skip |= LogError(
7087 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7088 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
7089 "not be "
7090 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7091 i, j);
7092 found = true;
7093 }
7094 if (found) break;
7095 }
7096 }
7097 return skip;
7098}
7099
7100bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7101 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7102 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7103 bool skip = false;
7104 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7105 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007106 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7107 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007108 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7109 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7110 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7111 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7112 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7113 }
7114 return skip;
7115}
sfricke-samsungecafb192021-01-17 08:21:14 -08007116
7117bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7118 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7119 const VkAllocationCallbacks *pAllocator,
7120 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7121 bool skip = false;
7122 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7123 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7124 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7125 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7126 }
7127 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007128}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007129
7130bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7131 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7132 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7133 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7134 bool skip = false;
7135 const auto *vertex_input_dynamic_state_features =
7136 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7137 const auto *vertex_attribute_divisor_features =
7138 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7139
7140 // VUID-vkCmdSetVertexInputEXT-None-04790
7141 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7142 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7143 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7144 }
7145
7146 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7147 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7148 skip |=
7149 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7150 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7151 }
7152
7153 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7154 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7155 skip |= LogError(
7156 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7157 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7158 }
7159
7160 // VUID-vkCmdSetVertexInputEXT-binding-04793
7161 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7162 bool binding_found = false;
7163 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7164 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7165 binding_found = true;
7166 break;
7167 }
7168 }
7169 if (!binding_found) {
7170 skip |=
7171 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7172 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
7173 }
7174 }
7175
7176 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7177 if (vertexBindingDescriptionCount > 1) {
7178 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7179 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7180 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7181 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7182 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
7183 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
7184 }
7185 }
7186 }
7187 }
7188
7189 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7190 if (vertexAttributeDescriptionCount > 1) {
7191 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7192 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7193 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7194 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7195 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
7196 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
7197 }
7198 }
7199 }
7200 }
7201
7202 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7203 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7204 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
7205 skip |= LogError(
7206 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7207 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
7208 }
7209
7210 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7211 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
7212 skip |= LogError(
7213 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7214 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
7215 binding);
7216 }
7217
7218 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7219 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7220 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7221 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7222 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7223 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7224 binding);
7225 }
7226
7227 if (pVertexBindingDescriptions[binding].divisor > 1) {
7228 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7229 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7230 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7231 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7232 "vertexAttributeInstanceRateDivisor is not enabled",
7233 binding);
7234 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007235 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007236 if (pVertexBindingDescriptions[binding].divisor >
7237 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7238 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007239 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007240 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7241 binding);
7242 }
7243
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007244 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007245 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7246 skip |=
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007247 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007248 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7249 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7250 binding);
7251 }
7252 }
7253 }
7254 }
7255
7256 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007257 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007258 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7259 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007260 device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007261 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7262 attribute);
7263 }
7264
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007265 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007266 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7267 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007268 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007269 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7270 attribute);
7271 }
7272
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007273 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007274 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7275 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007276 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007277 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7278 attribute);
7279 }
7280
7281 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7282 VkFormatProperties properties;
7283 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7284 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7285 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7286 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7287 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7288 attribute);
7289 }
7290 }
7291
7292 return skip;
7293}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007294
7295bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7296 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7297 const void *pValues) const {
7298 bool skip = false;
7299 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7300 // Check that offset + size don't exceed the max.
7301 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7302 if (offset >= max_push_constants_size) {
7303 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7304 "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset,
7305 max_push_constants_size);
7306 }
7307 if (size > max_push_constants_size - offset) {
7308 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
7309 "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.",
7310 offset, size, max_push_constants_size);
7311 }
7312
7313 // size needs to be non-zero and a multiple of 4.
7314 if (size & 0x3) {
7315 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.",
7316 size);
7317 }
7318
7319 // offset needs to be a multiple of 4.
7320 if ((offset & 0x3) != 0) {
7321 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007322 "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007323 }
7324 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007325}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007326
7327bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7328 uint32_t srcCacheCount,
7329 const VkPipelineCache *pSrcCaches) const {
7330 bool skip = false;
7331 if (pSrcCaches) {
7332 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7333 if (pSrcCaches[index0] == dstCache) {
7334 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7335 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7336 report_data->FormatHandle(dstCache).c_str());
7337 break;
7338 }
7339 }
7340 }
7341 return skip;
7342}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007343
7344bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
7345 VkImageLayout imageLayout, const VkClearColorValue *pColor,
7346 uint32_t rangeCount,
7347 const VkImageSubresourceRange *pRanges) const {
7348 bool skip = false;
7349 if (!pColor) {
7350 skip |=
7351 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
7352 }
7353 return skip;
7354}
7355
7356bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
7357 const VkRenderPassBeginInfo *const rp_begin) const {
7358 bool skip = false;
7359 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
7360 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
7361 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
7362 "), but VkRenderPassBeginInfo::pClearValues is not null.",
7363 func_name, rp_begin->clearValueCount);
7364 }
7365 return skip;
7366}
7367
7368bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7369 VkSubpassContents) const {
7370 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
7371 return skip;
7372}
7373
7374bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
7375 const VkRenderPassBeginInfo *pRenderPassBegin,
7376 const VkSubpassBeginInfo *) const {
7377 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
7378 return skip;
7379}
7380
7381bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7382 const VkSubpassBeginInfo *) const {
7383 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
7384 return skip;
7385}