blob: 432ae5f52116b26a75d4ec5977491012d65ab949 [file] [log] [blame]
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070028static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060029
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070036read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); }
37write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); }
38
Jeremy Gebbencbf22862021-03-03 12:01:22 -070039static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070040static ReadWriteLock secondary_cb_map_mutex;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -070041static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); }
42static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070044bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050045 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060046 bool skip = false;
47
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070048 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060049
50 if (result == VK_STRING_ERROR_NONE) {
51 return skip;
52 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070053 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070054 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060055 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070056 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
57 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060058 }
59 return skip;
60}
61
Jeff Bolz46c0ea02019-10-09 13:06:29 -050062bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060063 bool skip = false;
64 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
65 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080066 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
67 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070068 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
69 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
70 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060071 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070072 skip |= LogWarning(instance, kVUIDUndefined,
73 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
74 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
75 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060076 }
77 }
78 return skip;
79}
80
Jeff Bolz46c0ea02019-10-09 13:06:29 -050081bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060082 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060083 // Create and use a local instance extension object, as an actual instance has not been created yet
84 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
85 InstanceExtensions local_instance_extensions;
86 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
87
John Zulauf620755c2018-04-16 11:00:43 -060088 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060089 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
90 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060091 }
92
93 return skip;
94}
95
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060096bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -070097 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060098 // Struct is legal IF it's supported
99 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
100 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
101 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
102 if (enum_iter != dev_exts_enumerated->second.cend()) {
103 return true;
104 }
105 }
106 return false;
107}
108
Tony-LunarG866843d2020-05-13 11:22:42 -0600109bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
110 const VkValidationFeaturesEXT *validation_features) const {
111 bool skip = false;
112 bool debug_printf = false;
113 bool gpu_assisted = false;
114 bool reserve_slot = false;
115 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
116 switch (validation_features->pEnabledValidationFeatures[i]) {
117 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
118 gpu_assisted = true;
119 break;
120
121 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
122 debug_printf = true;
123 break;
124
125 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
126 reserve_slot = true;
127 break;
128
129 default:
130 break;
131 }
132 }
133 if (reserve_slot && !gpu_assisted) {
134 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
135 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
136 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
137 }
138 if (gpu_assisted && debug_printf) {
139 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
140 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
141 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
142 }
143
144 return skip;
145}
146
John Zulauf620755c2018-04-16 11:00:43 -0600147template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700148ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
149 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600150 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700151 ExtEnabled state =
152 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600153 return state;
154}
155
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700156bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500157 const VkAllocationCallbacks *pAllocator,
158 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 bool skip = false;
160 // Note: From the spec--
161 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
162 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
163 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700164 ? pCreateInfo->pApplicationInfo->apiVersion
165 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700166 skip |= validate_api_version(local_api_version, api_version);
167 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700168 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600169 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
170
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700171 return skip;
172}
173
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700174void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700175 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
176 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700177 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
178 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700179 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700180 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700181}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600182
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700183void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
184 // Assume phys_devices is valid
185 assert(phys_devices);
186 for (int i = 0; i < count; ++i) {
187 const auto &phys_device = phys_devices[i];
188 if (0 == physical_device_properties_map.count(phys_device)) {
189 auto phys_dev_props = new VkPhysicalDeviceProperties;
190 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
191 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600192
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700193 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
194 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700195 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700196 std::vector<VkExtensionProperties> ext_props{};
197 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
198 ext_props.resize(ext_count);
199 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
200 for (uint32_t j = 0; j < ext_count; j++) {
201 dev_exts_enumerated.insert(ext_props[j].extensionName);
202 }
203 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600204 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700205 }
206}
207
208void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
209 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
210 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
211 return;
212 }
213
214 if (pPhysicalDeviceCount && pPhysicalDevices) {
215 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
216 }
217}
218
219void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
220 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
221 VkResult result) {
222 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
223 return;
224 }
225
226 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
227 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
228 const auto &group = pPhysicalDeviceGroupProperties[i];
229 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
230 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600231 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700232}
233
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600234void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
235 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
236 delete (it->second);
237 it = physical_device_properties_map.erase(it);
238 }
239};
240
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700241void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700242 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700243 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700244 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700245 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
246 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700247
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248 // Parmeter validation also uses extension data
249 stateless_validation->device_extensions = this->device_extensions;
250
251 VkPhysicalDeviceProperties device_properties = {};
252 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600253 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700254 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
255
256 if (device_extensions.vk_nv_shading_rate_image) {
257 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700258 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
259 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600260 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700261 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
262 }
263
264 if (device_extensions.vk_nv_mesh_shader) {
265 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700266 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
267 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600268 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700269 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
270 }
271
Jason Macnak5c954952019-07-09 15:46:12 -0700272 if (device_extensions.vk_nv_ray_tracing) {
273 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700274 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
275 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700276 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500277 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
278 }
279
sourav parmarcd5fb182020-07-17 12:58:44 -0700280 if (device_extensions.vk_khr_ray_tracing_pipeline) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500281 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700282 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
283 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500284 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
285 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700286 }
287
sourav parmarcd5fb182020-07-17 12:58:44 -0700288 if (device_extensions.vk_khr_acceleration_structure) {
289 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700290 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
291 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700292 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
293 phys_dev_ext_props.acc_structure_props = acc_structure_props;
294 }
295
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700296 if (device_extensions.vk_ext_transform_feedback) {
297 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700298 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
299 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700300 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
301 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
302 }
303
Piers Daniellcb6d8032021-04-19 18:51:26 -0600304 if (device_extensions.vk_ext_vertex_attribute_divisor) {
305 // Get the needed vertex attribute divisor limits
306 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
307 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
308 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
309 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
310 }
311
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800312 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
313
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700314 // Save app-enabled features in this device's validation object
315 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700316 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200317 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
318 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
319 if (features2) {
320 tmp_features2_state.features = features2->features;
321 } else if (pCreateInfo->pEnabledFeatures) {
322 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700323 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200324 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700325 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200326 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700327 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200328 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700329}
330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700331bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500332 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600333 bool skip = false;
334
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200335 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
336 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
337 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600338 }
339
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700340 // If this device supports VK_KHR_portability_subset, it must be enabled
341 const std::string portability_extension_name("VK_KHR_portability_subset");
342 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
343 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
344 bool portability_requested = false;
345
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200346 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
347 skip |=
348 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
349 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
350 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
351 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700352 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
353 portability_requested = true;
354 }
355 }
356
357 if (portability_supported && !portability_requested) {
358 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
359 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
360 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600361 }
362
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200363 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700364 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
365 bool negative_viewport =
366 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200367 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700368 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
369 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
370 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200371 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600372 }
373
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600374 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200375 bool khr_bda =
376 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
377 bool ext_bda =
378 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600379 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700380 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
381 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
382 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600383 }
384 }
385
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600386 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
387 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700388 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600389 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800390 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700391 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800392 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700393 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600394 }
395 }
396
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700397 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500398 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700399 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500400 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
401 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
402 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
403 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700404 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700405 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
406 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
407 skip |= LogError(
408 device,
409 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
410 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
411 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700412 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700413 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600414 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
415 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
416 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
417 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600418 }
419
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700420 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700421 if (vulkan_11_features) {
422 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
423 while (current) {
424 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
425 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
426 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
427 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
428 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
429 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700430 skip |= LogError(
431 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700432 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
433 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
434 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
435 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
436 break;
437 }
438 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
439 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800440
441 // Check features are enabled if matching extension is passed in as well
442 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
443 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
444 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
445 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
446 skip |= LogError(
447 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
448 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
449 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
450 }
451 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700452 }
453
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700454 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700455 if (vulkan_12_features) {
456 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
457 while (current) {
458 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
459 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
460 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
461 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
462 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
463 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
464 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
465 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
466 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
467 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
469 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
470 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700471 skip |= LogError(
472 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700473 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
474 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
475 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
476 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
477 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
478 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
479 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
480 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
481 break;
482 }
483 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
484 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700485 // Check features are enabled if matching extension is passed in as well
486 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
487 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
488 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
489 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
490 skip |= LogError(
491 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
492 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
493 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
494 }
495 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
496 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
497 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
498 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
499 "is not VK_TRUE.",
500 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
501 }
502 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
503 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
504 skip |= LogError(
505 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
506 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
507 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
508 }
509 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
510 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
511 skip |= LogError(
512 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
513 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
514 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
515 }
516 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
517 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
518 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
519 skip |=
520 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
521 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
522 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
523 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
524 }
525 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700526 }
527
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600528 // Validate pCreateInfo->pQueueCreateInfos
529 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600530
531 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700532 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
533 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600534 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700535 skip |=
536 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
537 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
538 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
539 "index value.",
540 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600541 }
542
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700543 if (queue_create_info.pQueuePriorities != nullptr) {
544 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
545 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600546 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700547 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
548 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
549 "] (=%f) is not between 0 and 1 (inclusive).",
550 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600551 }
552 }
553 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700554
555 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700556 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700557 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700558 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700559 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700560 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700561 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700562 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700563 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700564 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700565 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
566 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
567 "protectedMemory feature being set as well.");
568 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600569 }
570 }
571
sfricke-samsung30a57412020-05-15 21:14:54 -0700572 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700573 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700574 VkBool32 variable_pointers = VK_FALSE;
575 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700576 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700577 variable_pointers = vulkan_11_features->variablePointers;
578 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700579 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700580 variable_pointers = variable_pointers_features->variablePointers;
581 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700582 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700583 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700584 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
585 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
586 }
587
sfricke-samsungfd76c342020-05-29 23:13:43 -0700588 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700589 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700590 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700591 VkBool32 multiview_geometry_shader = VK_FALSE;
592 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700593 if (vulkan_11_features) {
594 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700595 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
596 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700597 } else if (multiview_features) {
598 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700599 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
600 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700601 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700602 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700603 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
604 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
605 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700606 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700607 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
608 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
609 }
610
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600611 return skip;
612}
613
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500614bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700615 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700616 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
617 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
618 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600619 }
620
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700621 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600622}
623
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700624bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500625 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100626 bool skip = false;
627
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600628 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700629 skip |=
630 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600631
632 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
633 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
634 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
635 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700636 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
637 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
638 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600639 }
640
641 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
642 // queueFamilyIndexCount uint32_t values
643 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
645 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
646 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
647 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600648 }
649 }
650
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700651 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
652 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
653 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
654 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
655 }
656
657 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
658 skip |=
659 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
660 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
661 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
662 }
663
664 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
665 skip |=
666 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
667 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
668 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
669 }
670
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600671 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
672 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
673 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
674 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700675 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
676 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
677 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600678 }
679 }
680
681 return skip;
682}
683
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700684bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500685 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600686 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600687
688 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800689 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700690 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600691 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
692 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
693 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
694 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700695 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
696 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
697 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600698 }
699
700 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
701 // queueFamilyIndexCount uint32_t values
702 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700703 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
704 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
705 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
706 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600707 }
708 }
709
Dave Houlton413a6782018-05-22 13:01:54 -0600710 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600712 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700713 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600714 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700715 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600716
Dave Houlton413a6782018-05-22 13:01:54 -0600717 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600719 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700720 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600721
Dave Houlton130c0212018-01-29 13:39:56 -0700722 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700723 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
724 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700725 skip |= LogError(
726 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600727 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
728 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700729 }
730
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600731 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100732 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
733 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700734 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
735 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
736 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600737 }
738
739 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700740 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100741 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700742 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
743 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
744 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
745 ") are not equal.",
746 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100747 }
748
749 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
751 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
752 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
753 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100754 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600755 }
756
757 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700758 skip |= LogError(
759 device, "VUID-VkImageCreateInfo-imageType-00957",
760 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600761 }
762 }
763
Dave Houlton130c0212018-01-29 13:39:56 -0700764 // 3D image may have only 1 layer
765 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
767 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700768 }
769
Dave Houlton130c0212018-01-29 13:39:56 -0700770 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
771 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
772 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
773 // At least one of the legal attachment bits must be set
774 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700775 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
776 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700777 }
778 // No flags other than the legal attachment bits may be set
779 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
780 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
782 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700783 }
784 }
785
Jeff Bolzef40fec2018-09-01 22:04:34 -0500786 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700787 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500788 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700789 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700790 ? static_cast<uint32_t>(ceil(log2(max_dim)))
791 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
792 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600793 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700794 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
795 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
796 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600797 }
798
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700799 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700800 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
801 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
802 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600803 }
804
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700805 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700806 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
807 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
808 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100809 }
810
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700811 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700812 skip |= LogError(
813 device, "VUID-VkImageCreateInfo-flags-01924",
814 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
815 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
816 }
817
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600818 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
819 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700820 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
821 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700822 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
823 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
824 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600825 }
826
827 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700828 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600829 // Linear tiling is unsupported
830 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700831 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700832 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
833 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600834 }
835
836 // Sparse 1D image isn't valid
837 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700838 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
839 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600840 }
841
842 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700843 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700844 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
845 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
846 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600847 }
848
849 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700850 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700851 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
852 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
853 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600854 }
855
856 // Multi-sample 2D image when device doesn't support it
857 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700858 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600859 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700860 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
861 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
862 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700863 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600864 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700865 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
866 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
867 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700868 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600869 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700870 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
871 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
872 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700873 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600874 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700875 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
876 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
877 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600878 }
879 }
880 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500881
Jeff Bolz9af91c52018-09-01 21:53:57 -0500882 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
883 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700884 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
885 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
886 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500887 }
888 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700889 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
890 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
891 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500892 }
893 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700894 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
895 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
896 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500897 }
898 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500899
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700900 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600901 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700902 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
903 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
904 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500905 }
906
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700907 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700908 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
909 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800910 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
911 "depth/stencil format.",
912 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500913 }
914
Dave Houlton142c4cb2018-10-17 15:04:41 -0600915 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700916 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
917 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
918 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
919 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500920 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600921 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700922 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
923 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
924 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
925 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500926 }
927 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500928
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700929 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800930 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700931 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
932 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800933 "format (%s) must be a depth or depth/stencil format.",
934 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700935 }
936
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700937 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500938 if (image_stencil_struct != nullptr) {
939 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
940 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
941 // No flags other than the legal attachment bits may be set
942 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
943 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700944 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
945 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
946 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
947 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500948 }
949 }
950
sfricke-samsung61a57c02021-01-10 21:35:12 -0800951 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500952 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
953 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800954 skip |= LogError(
955 device, "VUID-VkImageCreateInfo-Format-02536",
956 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
957 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
958 "maxFramebufferWidth (%u)",
959 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500960 }
961
962 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800963 skip |= LogError(
964 device, "VUID-VkImageCreateInfo-format-02537",
965 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
966 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
967 "maxFramebufferHeight (%u)",
968 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500969 }
970 }
971
972 if (!physical_device_features.shaderStorageImageMultisample &&
973 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
974 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
975 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700976 LogError(device, "VUID-VkImageCreateInfo-format-02538",
977 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
978 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
979 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500980 }
981
982 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
983 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700984 skip |= LogError(
985 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500986 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
987 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
988 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
989 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
990 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700991 skip |= LogError(
992 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500993 "vkCreateImage(): Depth-stencil image in which usage does not include "
994 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
995 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
996 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
997 }
998
999 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1000 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001001 skip |= LogError(
1002 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001003 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1004 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1005 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1006 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1007 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001008 skip |= LogError(
1009 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001010 "vkCreateImage(): Depth-stencil image in which usage does not include "
1011 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1012 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1013 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1014 }
1015 }
1016 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001017
1018 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1019 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1020 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1021 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1022 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1023 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001024
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001025 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001026 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001027 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1028 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001029 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1030 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1031 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1032 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1033 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1034 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1035 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001036 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001037 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1038 } else if (drm_format_mod_list != nullptr) {
1039 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1040 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1041 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001042 }
1043 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1044 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1045 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1046 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1047 "in the pNext chain");
1048 }
1049 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001050
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001051 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001052 bool image_create_maybe_linear = false;
1053 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1054 image_create_maybe_linear = true;
1055 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1056 image_create_maybe_linear = false;
1057 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1058 image_create_maybe_linear =
1059 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001060 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001061 }
1062
1063 // If multi-sample, validate type, usage, tiling and mip levels.
1064 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001065 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001066 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1067 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1068 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1069 }
1070
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001071 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001072 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1073 image_create_maybe_linear)) {
1074 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1075 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1076 }
1077
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001078 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1079 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1080 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1081 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1082 "imageType must be VK_IMAGE_TYPE_2D.");
1083 }
1084 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1085 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1086 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1087 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1088 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001089 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001090 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001091 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1092 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1093 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1094 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1095 }
1096 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1097 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1098 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1099 "imageType must be VK_IMAGE_TYPE_2D.");
1100 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001101 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001102 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1103 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1104 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1105 }
1106 if (pCreateInfo->mipLevels != 1) {
1107 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1108 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1109 pCreateInfo->mipLevels);
1110 }
1111 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001112
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001113 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001114 if (swapchain_create_info != nullptr) {
1115 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1116 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1117 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1118 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1119 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1120 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1121
1122 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1123 // also implicitly forces the check above that extent.depth is 1
1124 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1125 string_VkImageType(pCreateInfo->imageType));
1126 }
1127 if (pCreateInfo->mipLevels != 1) {
1128 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1129 pCreateInfo->mipLevels);
1130 }
1131 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1132 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1133 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1134 }
1135 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1136 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1137 base_message, string_VkImageTiling(pCreateInfo->tiling));
1138 }
1139 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1140 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1141 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1142 }
1143 const VkImageCreateFlags valid_flags =
1144 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001145 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001146 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001147 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001148 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001149 }
1150 }
1151 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001152
1153 // If Chroma subsampled format ( _420_ or _422_ )
1154 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1155 skip |=
1156 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1157 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1158 ") must be a multiple of 2.",
1159 string_VkFormat(image_format), pCreateInfo->extent.width);
1160 }
1161 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1162 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1163 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1164 ") must be a multiple of 2.",
1165 string_VkFormat(image_format), pCreateInfo->extent.height);
1166 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001167
1168 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1169 if (format_list_info) {
1170 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1171 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1172 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1173 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1174 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1175 viewFormatCount);
1176 }
1177 // Check if viewFormatCount is not zero that it is all compatible
1178 for (uint32_t i = 0; i < viewFormatCount; i++) {
1179 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1180 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1181 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1182 "VkImageCreateInfo::format (%s) are not compatible.",
1183 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1184 }
1185 }
1186 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001187 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001188
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001189 return skip;
1190}
1191
Jeff Bolz99e3f632020-03-24 22:59:22 -05001192bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1193 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1194 bool skip = false;
1195
1196 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001197 // Validate feature set if using CUBE_ARRAY
1198 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1199 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1200 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1201 "enabling the imageCubeArray feature.");
1202 }
1203
Jeff Bolz99e3f632020-03-24 22:59:22 -05001204 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1205 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1206 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001207 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001208 pCreateInfo->subresourceRange.layerCount);
1209 }
1210 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001211 skip |= LogError(
1212 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1213 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1214 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001215 }
1216 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001217
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001218 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001219 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1220 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1221 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1222 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1223 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1224 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1225 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1226 }
1227 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1228 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1229 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1230 "not an ASTC format.",
1231 string_VkFormat(pCreateInfo->format));
1232 }
1233 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001234
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001235 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001236 if (ycbcr_conversion != nullptr) {
1237 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1238 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1239 skip |= LogError(
1240 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1241 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1242 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1243 "r swizzle = %s\n"
1244 "g swizzle = %s\n"
1245 "b swizzle = %s\n"
1246 "a swizzle = %s\n",
1247 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1248 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1249 }
1250 }
1251 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001252 }
1253 return skip;
1254}
1255
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001256bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001257 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001258 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001259
1260 // Note: for numerical correctness
1261 // - float comparisons should expect NaN (comparison always false).
1262 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1263
1264 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001265 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001266 if (v1_f <= 0.0f) return true;
1267
1268 float intpart;
1269 const float fract = modff(v1_f, &intpart);
1270
1271 assert(std::numeric_limits<float>::radix == 2);
1272 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1273 if (intpart >= u32_max_plus1) return false;
1274
1275 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001276 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001277 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001278 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001279 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001280 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001281 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001282 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001283 };
1284
1285 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1286 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1287 return (v1_f <= v2_f);
1288 };
1289
1290 // width
1291 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001292 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001293
1294 if (!(viewport.width > 0.0f)) {
1295 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001296 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1297 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001298 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1299 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001300 skip |= LogError(object, "VUID-VkViewport-width-01771",
1301 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1302 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001303 }
1304
1305 // height
1306 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001307 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001308 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001309
1310 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1311 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001312 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1313 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001314 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1315 height_healthy = false;
1316
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001317 skip |= LogError(object, "VUID-VkViewport-height-01773",
1318 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1319 ").",
1320 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001321 }
1322
1323 // x
1324 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001325 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001326 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001327 skip |= LogError(object, "VUID-VkViewport-x-01774",
1328 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1329 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001330 }
1331
1332 // x + width
1333 if (x_healthy && width_healthy) {
1334 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001335 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001336 skip |= LogError(
1337 object, "VUID-VkViewport-x-01232",
1338 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1339 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1340 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001341 }
1342 }
1343
1344 // y
1345 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001346 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001347 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001348 skip |= LogError(object, "VUID-VkViewport-y-01775",
1349 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1350 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001351 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001352 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001353 skip |= LogError(object, "VUID-VkViewport-y-01776",
1354 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1355 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001356 }
1357
1358 // y + height
1359 if (y_healthy && height_healthy) {
1360 const float boundary = viewport.y + viewport.height;
1361
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001362 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001363 skip |= LogError(object, "VUID-VkViewport-y-01233",
1364 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1365 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1366 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001367 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001368 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001369 LogError(object, "VUID-VkViewport-y-01777",
1370 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1371 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1372 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001373 }
1374 }
1375
sfricke-samsungfd06d422021-01-22 02:17:21 -08001376 // The extension was not created with a feature bit whichs prevents displaying the 2 variations of the VUIDs
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001377 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001378 // minDepth
1379 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001380 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001381 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001382 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1383 "[0.0, 1.0] range.",
1384 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001385 }
1386
1387 // maxDepth
1388 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001389 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001390 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001391 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1392 "[0.0, 1.0] range.",
1393 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001394 }
1395 }
1396
1397 return skip;
1398}
1399
Dave Houlton142c4cb2018-10-17 15:04:41 -06001400struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001401 VkShadingRatePaletteEntryNV shadingRate;
1402 uint32_t width;
1403 uint32_t height;
1404};
1405
1406// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001407static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001408 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1409 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1410 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1411 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1412 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1413 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001414};
1415
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001416bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001417 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001418
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001419 SampleOrderInfo *sample_order_info;
1420 uint32_t info_idx = 0;
1421 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1422 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1423 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001424 break;
1425 }
1426 }
1427
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001428 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001429 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1430 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1431 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001432 return skip;
1433 }
1434
Dave Houlton142c4cb2018-10-17 15:04:41 -06001435 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001436 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001437 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1438 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1439 ") must "
1440 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1441 "is set in framebufferNoAttachmentsSampleCounts.",
1442 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001443 }
1444
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001445 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001446 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1447 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1448 ") must "
1449 "be equal to the product of sampleCount (=%" PRIu32
1450 "), the fragment width for shadingRate "
1451 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001452 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001453 }
1454
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001455 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001456 skip |= LogError(
1457 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001458 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1459 ") must "
1460 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001461 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001462 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001463
1464 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001465 // the first width*height*sampleCount bits to all be set. Note: There is no
1466 // guarantee that 64 bits is enough, but practically it's unlikely for an
1467 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001468 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001469 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001470 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001471 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1472 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001473 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1474 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001475 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001476 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001477 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1478 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001479 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001480 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001481 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1482 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001483 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001484 uint32_t idx =
1485 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1486 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001487 }
1488
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001489 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1490 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001491 skip |= LogError(
1492 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001493 "The array pSampleLocations must contain exactly one entry for "
1494 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001495 }
1496
1497 return skip;
1498}
1499
sfricke-samsung51303fb2021-05-09 19:09:13 -07001500bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1501 const VkAllocationCallbacks *pAllocator,
1502 VkPipelineLayout *pPipelineLayout) const {
1503 bool skip = false;
1504 // Validate layout count against device physical limit
1505 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1506 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
1507 "vkCreatePipelineLayout(): setLayoutCount (%d) exceeds physical device maxBoundDescriptorSets limit (%d).",
1508 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1509 }
1510
1511 // Validate Push Constant ranges
1512 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1513 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1514 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1515 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1516 // Check that offset + size don't exceed the max.
1517 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1518 if (offset >= max_push_constants_size) {
1519 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
1520 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) that exceeds this "
1521 "device's maxPushConstantSize of %u.",
1522 i, offset, max_push_constants_size);
1523 }
1524 if (size > max_push_constants_size - offset) {
1525 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
1526 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u] offset (%u) and size (%u) "
1527 "together exceeds this device's maxPushConstantSize of %u.",
1528 i, offset, size, max_push_constants_size);
1529 }
1530
1531 // size needs to be non-zero and a multiple of 4.
1532 if (size == 0) {
1533 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
1534 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not greater than zero.",
1535 i, size);
1536 }
1537 if (size & 0x3) {
1538 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
1539 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not a multiple of 4.", i,
1540 size);
1541 }
1542
1543 // offset needs to be a multiple of 4.
1544 if ((offset & 0x3) != 0) {
1545 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
1546 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) is not a multiple of 4.",
1547 i, offset);
1548 }
1549 }
1550
1551 // As of 1.0.28, there is a VU that states that a stage flag cannot appear more than once in the list of push constant ranges.
1552 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1553 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1554 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
1555 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1556 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %d and %d.", i, j);
1557 }
1558 }
1559 }
1560 return skip;
1561}
1562
ziga-lunargc6341372021-07-28 12:57:42 +02001563bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1564 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1565 bool skip = false;
1566
1567 const auto *required_subgroup_size_features =
1568 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1569
1570 if (required_subgroup_size_features) {
1571 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1572 skip |= LogError(
1573 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1574 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1575 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1576 func_name, msg, pCreateInfo->flags);
1577 }
1578 }
1579
1580 return skip;
1581}
1582
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001583bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1584 uint32_t createInfoCount,
1585 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1586 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001587 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001588 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001589
1590 if (pCreateInfos != nullptr) {
1591 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001592 bool has_dynamic_viewport = false;
1593 bool has_dynamic_scissor = false;
1594 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001595 bool has_dynamic_depth_bias = false;
1596 bool has_dynamic_blend_constant = false;
1597 bool has_dynamic_depth_bounds = false;
1598 bool has_dynamic_stencil_compare = false;
1599 bool has_dynamic_stencil_write = false;
1600 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001601 bool has_dynamic_viewport_w_scaling_nv = false;
1602 bool has_dynamic_discard_rectangle_ext = false;
1603 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001604 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001605 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001606 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001607 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001608 bool has_dynamic_cull_mode = false;
1609 bool has_dynamic_front_face = false;
1610 bool has_dynamic_primitive_topology = false;
1611 bool has_dynamic_viewport_with_count = false;
1612 bool has_dynamic_scissor_with_count = false;
1613 bool has_dynamic_vertex_input_binding_stride = false;
1614 bool has_dynamic_depth_test_enable = false;
1615 bool has_dynamic_depth_write_enable = false;
1616 bool has_dynamic_depth_compare_op = false;
1617 bool has_dynamic_depth_bounds_test_enable = false;
1618 bool has_dynamic_stencil_test_enable = false;
1619 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001620 bool has_patch_control_points = false;
1621 bool has_rasterizer_discard_enable = false;
1622 bool has_depth_bias_enable = false;
1623 bool has_logic_op = false;
1624 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001625 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001626 if (pCreateInfos[i].pDynamicState != nullptr) {
1627 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1628 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1629 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001630 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1631 if (has_dynamic_viewport == true) {
1632 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1633 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1634 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1635 i);
1636 }
1637 has_dynamic_viewport = true;
1638 }
1639 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1640 if (has_dynamic_scissor == true) {
1641 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1642 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1643 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1644 i);
1645 }
1646 has_dynamic_scissor = true;
1647 }
1648 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1649 if (has_dynamic_line_width == true) {
1650 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1651 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1652 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1653 i);
1654 }
1655 has_dynamic_line_width = true;
1656 }
1657 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1658 if (has_dynamic_depth_bias == true) {
1659 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1660 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1661 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1662 i);
1663 }
1664 has_dynamic_depth_bias = true;
1665 }
1666 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1667 if (has_dynamic_blend_constant == true) {
1668 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1669 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1670 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1671 i);
1672 }
1673 has_dynamic_blend_constant = true;
1674 }
1675 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1676 if (has_dynamic_depth_bounds == true) {
1677 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1678 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1679 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1680 i);
1681 }
1682 has_dynamic_depth_bounds = true;
1683 }
1684 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1685 if (has_dynamic_stencil_compare == true) {
1686 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1687 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1688 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1689 i);
1690 }
1691 has_dynamic_stencil_compare = true;
1692 }
1693 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1694 if (has_dynamic_stencil_write == true) {
1695 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1696 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1697 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1698 i);
1699 }
1700 has_dynamic_stencil_write = true;
1701 }
1702 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1703 if (has_dynamic_stencil_reference == true) {
1704 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1705 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1706 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1707 i);
1708 }
1709 has_dynamic_stencil_reference = true;
1710 }
1711 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1712 if (has_dynamic_viewport_w_scaling_nv == true) {
1713 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1714 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1715 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1716 i);
1717 }
1718 has_dynamic_viewport_w_scaling_nv = true;
1719 }
1720 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1721 if (has_dynamic_discard_rectangle_ext == true) {
1722 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1723 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1724 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1725 i);
1726 }
1727 has_dynamic_discard_rectangle_ext = true;
1728 }
1729 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1730 if (has_dynamic_sample_locations_ext == true) {
1731 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1732 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1733 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1734 i);
1735 }
1736 has_dynamic_sample_locations_ext = true;
1737 }
1738 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1739 if (has_dynamic_exclusive_scissor_nv == true) {
1740 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1741 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1742 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1743 i);
1744 }
1745 has_dynamic_exclusive_scissor_nv = true;
1746 }
1747 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1748 if (has_dynamic_shading_rate_palette_nv == true) {
1749 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1750 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1751 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1752 i);
1753 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001754 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001755 }
1756 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1757 if (has_dynamic_viewport_course_sample_order_nv == true) {
1758 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1759 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1760 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1761 i);
1762 }
1763 has_dynamic_viewport_course_sample_order_nv = true;
1764 }
1765 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1766 if (has_dynamic_line_stipple == true) {
1767 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1768 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1769 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1770 i);
1771 }
1772 has_dynamic_line_stipple = true;
1773 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001774 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1775 if (has_dynamic_cull_mode) {
1776 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1777 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1778 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1779 i);
1780 }
1781 has_dynamic_cull_mode = true;
1782 }
1783 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1784 if (has_dynamic_front_face) {
1785 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1786 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1787 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1788 i);
1789 }
1790 has_dynamic_front_face = true;
1791 }
1792 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1793 if (has_dynamic_primitive_topology) {
1794 skip |= LogError(
1795 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1796 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1797 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1798 i);
1799 }
1800 has_dynamic_primitive_topology = true;
1801 }
1802 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1803 if (has_dynamic_viewport_with_count) {
1804 skip |= LogError(
1805 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1806 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1807 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1808 i);
1809 }
1810 has_dynamic_viewport_with_count = true;
1811 }
1812 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1813 if (has_dynamic_scissor_with_count) {
1814 skip |= LogError(
1815 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1816 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1817 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1818 i);
1819 }
1820 has_dynamic_scissor_with_count = true;
1821 }
1822 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1823 if (has_dynamic_vertex_input_binding_stride) {
1824 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1825 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1826 "listed twice in the "
1827 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1828 i);
1829 }
1830 has_dynamic_vertex_input_binding_stride = true;
1831 }
1832 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1833 if (has_dynamic_depth_test_enable) {
1834 skip |= LogError(
1835 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1836 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1837 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1838 i);
1839 }
1840 has_dynamic_depth_test_enable = true;
1841 }
1842 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1843 if (has_dynamic_depth_write_enable) {
1844 skip |= LogError(
1845 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1846 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1847 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1848 i);
1849 }
1850 has_dynamic_depth_write_enable = true;
1851 }
1852 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1853 if (has_dynamic_depth_compare_op) {
1854 skip |=
1855 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1856 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1857 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1858 i);
1859 }
1860 has_dynamic_depth_compare_op = true;
1861 }
1862 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1863 if (has_dynamic_depth_bounds_test_enable) {
1864 skip |= LogError(
1865 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1866 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1867 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1868 i);
1869 }
1870 has_dynamic_depth_bounds_test_enable = true;
1871 }
1872 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1873 if (has_dynamic_stencil_test_enable) {
1874 skip |= LogError(
1875 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1876 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1877 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1878 i);
1879 }
1880 has_dynamic_stencil_test_enable = true;
1881 }
1882 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1883 if (has_dynamic_stencil_op) {
1884 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1885 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1886 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1887 i);
1888 }
1889 has_dynamic_stencil_op = true;
1890 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001891 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1892 // Not allowed for graphics pipelines
1893 skip |= LogError(
1894 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1895 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1896 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1897 i, state_index);
1898 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001899 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1900 if (has_patch_control_points) {
1901 skip |= LogError(
1902 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1903 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1904 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1905 i);
1906 }
1907 has_patch_control_points = true;
1908 }
1909 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1910 if (has_rasterizer_discard_enable) {
1911 skip |= LogError(
1912 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1913 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1914 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1915 i);
1916 }
1917 has_rasterizer_discard_enable = true;
1918 }
1919 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1920 if (has_depth_bias_enable) {
1921 skip |= LogError(
1922 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1923 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1924 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1925 i);
1926 }
1927 has_depth_bias_enable = true;
1928 }
1929 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1930 if (has_logic_op) {
1931 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1932 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1933 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1934 i);
1935 }
1936 has_logic_op = true;
1937 }
1938 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1939 if (has_primitive_restart_enable) {
1940 skip |= LogError(
1941 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1942 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1943 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1944 i);
1945 }
1946 has_primitive_restart_enable = true;
1947 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001948 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1949 if (has_dynamic_vertex_input) {
1950 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1951 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1952 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1953 i);
1954 }
1955 has_dynamic_vertex_input = true;
1956 }
Petr Kraus299ba622017-11-24 03:09:03 +01001957 }
1958 }
1959
sfricke-samsung3b944422021-01-23 02:15:19 -08001960 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1961 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1962 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1963 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1964 i);
1965 }
1966
1967 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1968 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1969 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1970 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1971 i);
1972 }
1973
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001974 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001975 if ((feedback_struct != nullptr) &&
1976 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001977 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1978 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1979 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1980 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1981 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001982 }
1983
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001984 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001985
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001986 // Collect active stages and other information
1987 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001988 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001989 bool has_eval = false;
1990 bool has_control = false;
1991 if (pCreateInfos[i].pStages != nullptr) {
1992 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1993 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1994
1995 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1996 has_control = true;
1997 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1998 has_eval = true;
1999 }
2000
2001 skip |= validate_string(
2002 "vkCreateGraphicsPipelines",
2003 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2004 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002005
2006 std::stringstream msg;
2007 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2008 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2009 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002010 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002011 }
2012
2013 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2014 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2015 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2016 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2017 pCreateInfos[i].pTessellationState,
2018 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2019 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2020
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002021 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002022 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2023
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002024 skip |= validate_struct_pnext(
2025 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2026 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2027 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2028 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2029 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2030 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002031
2032 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2033 pCreateInfos[i].pTessellationState->flags,
2034 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2035 }
2036
2037 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2038 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2039 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2040 pCreateInfos[i].pInputAssemblyState,
2041 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2042 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2043
2044 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2045 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002046 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002047
2048 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2049 pCreateInfos[i].pInputAssemblyState->flags,
2050 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2051
2052 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2053 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2054 pCreateInfos[i].pInputAssemblyState->topology,
2055 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2056
2057 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2058 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2059 }
2060
2061 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002062 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002063
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002064 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002065 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2066 "vkCreateGraphicsPipelines: pararameter "
2067 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
2068 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002069 }
2070
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002071 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002072 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2073 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2074 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2075 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002076 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2077 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002078 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002079 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2080 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002081 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002082 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2083 skip |=
2084 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2085 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2086 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2087 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2088 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2089
2090 skip |= validate_array(
2091 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2092 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2093 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2094 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2095
2096 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002097 for (uint32_t vertex_binding_description_index = 0;
2098 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2099 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002100 skip |= validate_ranged_enum(
2101 "vkCreateGraphicsPipelines",
2102 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2103 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002104 pCreateInfos[i]
2105 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2106 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002107 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2108 }
2109 }
2110
2111 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002112 for (uint32_t vertex_attribute_description_index = 0;
2113 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2114 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002115 skip |= validate_ranged_enum(
2116 "vkCreateGraphicsPipelines",
2117 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2118 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002119 pCreateInfos[i]
2120 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2121 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002122 "VUID-VkVertexInputAttributeDescription-format-parameter");
2123 }
2124 }
2125
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002126 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002127 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2128 "vkCreateGraphicsPipelines: pararameter "
2129 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2130 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2131 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002132 }
2133
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002134 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002135 skip |=
2136 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2137 "vkCreateGraphicsPipelines: pararameter "
2138 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2139 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2140 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002141 }
2142
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002143 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002144 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2145 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002146 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2147 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002148 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2149 "vkCreateGraphicsPipelines: parameter "
2150 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2151 "(%" PRIu32 ") is not distinct.",
2152 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002153 }
2154 vertex_bindings.insert(vertex_bind_desc.binding);
2155
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002156 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002157 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2158 "vkCreateGraphicsPipelines: parameter "
2159 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2160 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2161 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002162 }
2163
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002164 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002165 skip |=
2166 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2167 "vkCreateGraphicsPipelines: parameter "
2168 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2169 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2170 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002171 }
2172 }
2173
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002174 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002175 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2176 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002177 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2178 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002179 skip |= LogError(
2180 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002181 "vkCreateGraphicsPipelines: parameter "
2182 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2183 i, d, vertex_attrib_desc.location);
2184 }
2185 attribute_locations.insert(vertex_attrib_desc.location);
2186
2187 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2188 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002189 skip |= LogError(
2190 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002191 "vkCreateGraphicsPipelines: parameter "
2192 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2193 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2194 i, d, vertex_attrib_desc.binding, i);
2195 }
2196
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002197 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002198 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2199 "vkCreateGraphicsPipelines: parameter "
2200 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2201 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2202 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002203 }
2204
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002205 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002206 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2207 "vkCreateGraphicsPipelines: parameter "
2208 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2209 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2210 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002211 }
2212
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002213 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002214 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2215 "vkCreateGraphicsPipelines: parameter "
2216 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2217 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2218 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002219 }
2220 }
2221 }
2222
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002223 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2224 if (has_control && has_eval) {
2225 if (pCreateInfos[i].pTessellationState == nullptr) {
2226 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2227 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2228 "shader stage and a tessellation evaluation shader stage, "
2229 "pCreateInfos[%d].pTessellationState must not be NULL.",
2230 i, i);
2231 } else {
2232 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2233 skip |= validate_struct_pnext(
2234 "vkCreateGraphicsPipelines",
2235 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2236 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2237 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2238 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002239
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002240 skip |= validate_reserved_flags(
2241 "vkCreateGraphicsPipelines",
2242 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2243 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002244
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002245 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2246 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2247 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2248 "vkCreateGraphicsPipelines: invalid parameter "
2249 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2250 "should be >0 and <=%u.",
2251 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2252 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253 }
2254 }
2255 }
2256
2257 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2258 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2259 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2260 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002261 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2262 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2263 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2264 "].pViewportState (=NULL) is not a valid pointer.",
2265 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002266 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002267 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2268
2269 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002270 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2271 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2272 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2273 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002274 }
2275
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002276 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002277 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002278 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2279 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002280 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2281 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002282 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002283 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002284 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002285 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002286 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002287 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2288 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002289 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2290 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2291 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002292 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002293
2294 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002295 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002296 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002297 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002299 auto exclusive_scissor_struct =
2300 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2301 auto shading_rate_image_struct =
2302 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2303 auto coarse_sample_order_struct =
2304 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002305 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002306 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002307 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002308 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002309
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002310 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002311 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002312 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2313 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2314 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2315 ") is not 1.",
2316 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002317 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002318
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002319 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002320 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2321 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2322 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2323 ") is not 1.",
2324 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002325 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002326
Dave Houlton142c4cb2018-10-17 15:04:41 -06002327 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2328 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002329 skip |= LogError(
2330 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2331 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2332 "disabled, but pCreateInfos[%" PRIu32
2333 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2334 ") is not 1.",
2335 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002336 }
2337
Jeff Bolz9af91c52018-09-01 21:53:57 -05002338 if (shading_rate_image_struct &&
2339 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002340 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2341 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2342 "disabled, but pCreateInfos[%" PRIu32
2343 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2344 ") is neither 0 nor 1.",
2345 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002346 }
2347
Petr Krausa6103552017-11-16 21:21:58 +01002348 } else { // multiViewport enabled
2349 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002350 if (!has_dynamic_viewport_with_count) {
2351 skip |= LogError(
2352 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2353 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2354 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002355 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002356 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2357 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2358 "].pViewportState->viewportCount (=%" PRIu32
2359 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2360 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002361 } else if (has_dynamic_viewport_with_count) {
2362 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2363 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2364 "].pViewportState->viewportCount (=%" PRIu32
2365 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2366 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002367 }
Petr Krausa6103552017-11-16 21:21:58 +01002368
2369 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002370 if (!has_dynamic_scissor_with_count) {
2371 skip |= LogError(
2372 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2373 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2374 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002375 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002376 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2377 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2378 "].pViewportState->scissorCount (=%" PRIu32
2379 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2380 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002381 } else if (has_dynamic_scissor_with_count) {
2382 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2383 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2384 "].pViewportState->scissorCount (=%" PRIu32
2385 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2386 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002387 }
2388 }
2389
ziga-lunarg845883b2021-07-14 15:05:00 +02002390 if (!has_dynamic_scissor && viewport_state.pScissors) {
2391 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2392 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002393
2394 if (scissor.offset.x < 0) {
2395 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2396 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2397 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2398 scissor.offset.x, i, scissor_i);
2399 }
2400
2401 if (scissor.offset.y < 0) {
2402 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2403 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2404 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2405 scissor.offset.y, i, scissor_i);
2406 }
2407
ziga-lunarg845883b2021-07-14 15:05:00 +02002408 const int64_t x_sum =
2409 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2410 if (x_sum > std::numeric_limits<int32_t>::max()) {
2411 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2412 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2413 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2414 "] will overflow int32_t.",
2415 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2416 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002417
ziga-lunarg845883b2021-07-14 15:05:00 +02002418 const int64_t y_sum =
2419 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2420 if (y_sum > std::numeric_limits<int32_t>::max()) {
2421 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2422 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2423 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2424 "] will overflow int32_t.",
2425 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2426 }
2427 }
2428 }
2429
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002430 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002431 skip |=
2432 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2433 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2434 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2435 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002436 }
2437
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002438 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002439 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2440 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2441 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2442 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2443 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002444 }
2445
Piers Daniell39842ee2020-07-10 16:42:33 -06002446 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2447 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002448 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2449 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2450 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2451 "].pViewportState->viewportCount (=%" PRIu32 ").",
2452 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002453 }
2454
Dave Houlton142c4cb2018-10-17 15:04:41 -06002455 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002456 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002457 skip |=
2458 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2459 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2460 ") must be zero or identical to pCreateInfos[%" PRIu32
2461 "].pViewportState->viewportCount (=%" PRIu32 ").",
2462 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002463 }
2464
Dave Houlton142c4cb2018-10-17 15:04:41 -06002465 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002466 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002467 skip |= LogError(
2468 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002469 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2470 "] "
2471 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2472 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2473 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002474 }
2475
Petr Krausa6103552017-11-16 21:21:58 +01002476 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002477 skip |= LogError(
2478 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002479 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2480 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002481 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2482 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002483 }
2484
2485 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002486 skip |= LogError(
2487 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002488 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2489 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002490 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2491 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002492 }
2493
Jeff Bolz3e71f782018-08-29 23:15:45 -05002494 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002495 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2496 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2497 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002498 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002499 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2500 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2501 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2502 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002503 }
2504
Jeff Bolz9af91c52018-09-01 21:53:57 -05002505 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002506 shading_rate_image_struct->viewportCount > 0 &&
2507 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002508 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002509 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002510 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002511 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2512 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002513 i, i);
2514 }
2515
Chris Mayer328d8212018-12-11 14:16:18 +01002516 if (vp_swizzle_struct) {
2517 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002518 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2519 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2520 " does "
2521 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2522 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002523 }
2524 }
2525
Petr Krausb3fcdb42018-01-09 22:09:09 +01002526 // validate the VkViewports
2527 if (!has_dynamic_viewport && viewport_state.pViewports) {
2528 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2529 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002530 const char *fn_name = "vkCreateGraphicsPipelines";
2531 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2532 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2533 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002534 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002535 }
2536 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002537
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002538 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002539 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2540 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2541 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2542 "VK_NV_clip_space_w_scaling extension is not enabled.",
2543 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002544 }
2545
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002546 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002547 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2548 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2549 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2550 "VK_EXT_discard_rectangles extension is not enabled.",
2551 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002552 }
2553
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002554 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002555 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2556 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2557 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2558 "VK_EXT_sample_locations extension is not enabled.",
2559 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002560 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002561
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002562 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002563 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2564 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2565 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2566 "VK_NV_scissor_exclusive extension is not enabled.",
2567 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002568 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002569
2570 if (coarse_sample_order_struct &&
2571 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2572 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002573 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2574 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2575 "] "
2576 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2577 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2578 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002579 }
2580
2581 if (coarse_sample_order_struct) {
2582 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002583 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002584 }
2585 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002586
2587 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2588 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002589 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2590 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2591 "] "
2592 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2593 ") "
2594 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2595 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002596 }
2597 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002598 skip |= LogError(
2599 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002600 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2601 "] "
2602 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2603 i);
2604 }
2605 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002606 }
2607
2608 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002609 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2610 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2611 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2612 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002613 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002614 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002615 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002616 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2617 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002618 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002619 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002620 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002621 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002622 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002623 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002624 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002625 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2626 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002627
2628 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002629 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002630 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002631 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002632
2633 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002634 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002635 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2636 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2637
2638 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002639 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002640 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2641 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002642 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002643 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002644
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002645 skip |= validate_flags(
2646 "vkCreateGraphicsPipelines",
2647 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2648 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002649 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002650
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002651 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002652 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002653 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2654 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2655
2656 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002657 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002658 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2659 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2660
2661 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002662 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002663 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2664 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2665 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002666 }
John Zulauf7acac592017-11-06 11:15:53 -07002667 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002668 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002669 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2670 "vkCreateGraphicsPipelines(): parameter "
2671 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2672 i);
John Zulauf7acac592017-11-06 11:15:53 -07002673 }
2674 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2675 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2676 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002677 skip |= LogError(
2678 device,
2679
Dave Houlton413a6782018-05-22 13:01:54 -06002680 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002681 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002682 }
2683 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002684
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002685 const auto *line_state =
2686 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002687
2688 if (line_state) {
2689 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2690 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2691 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2692 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002693 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2694 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2695 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2696 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002697 }
2698 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
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->alphaToOneEnable == VK_TRUE.",
2703 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002704 }
2705 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
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->sampleShadingEnable == VK_TRUE.",
2710 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002711 }
2712 }
2713 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2714 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2715 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002716 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2717 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2718 "range [1,256].",
2719 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002720 }
2721 }
2722 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002723 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002724 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2725 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002726 skip |=
2727 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2728 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2729 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2730 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002731 }
2732 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2733 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002734 skip |=
2735 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2736 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2737 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2738 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002739 }
2740 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2741 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002742 skip |=
2743 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2744 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2745 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2746 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002747 }
2748 if (line_state->stippledLineEnable) {
2749 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2750 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002751 skip |=
2752 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2753 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2754 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2755 "stippledRectangularLines feature.",
2756 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002757 }
2758 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2759 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002760 skip |=
2761 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2762 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2763 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2764 "stippledBresenhamLines feature.",
2765 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002766 }
2767 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2768 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002769 skip |=
2770 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2771 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2772 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2773 "stippledSmoothLines feature.",
2774 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002775 }
2776 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2777 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002778 skip |=
2779 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2780 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2781 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2782 "stippledRectangularLines and strictLines features.",
2783 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002784 }
2785 }
2786 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002787 }
2788
Petr Krause91f7a12017-12-14 20:57:36 +01002789 bool uses_color_attachment = false;
2790 bool uses_depthstencil_attachment = false;
2791 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002792 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002793 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2794 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002795 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002796 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002797 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002798 }
2799 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002800 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002801 }
Petr Krause91f7a12017-12-14 20:57:36 +01002802 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002803 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002804 }
2805
2806 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002807 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002808 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002809 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002810 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002811 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002812
2813 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002814 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002815 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002816 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002817
2818 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002819 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002820 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2821 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2822
2823 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002824 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002825 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2826 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2827
2828 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002829 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2831 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002832 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002833
2834 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002835 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002836 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2837 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2838
2839 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002840 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002841 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2842 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2843
2844 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002845 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002846 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2847 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002848 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002849
2850 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002851 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2853 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002854 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002855
2856 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002857 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002858 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2859 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002860 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002861
2862 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002863 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002864 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2865 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002866 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867
2868 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002869 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2871 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002872 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002873
2874 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002875 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2877 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002878 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002879
2880 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002881 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002882 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2883 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002884 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002885
2886 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002887 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002888 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2889 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002890 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002891
2892 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002893 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002894 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2895 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2896 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897 }
2898 }
2899
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002900 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002901 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2902
Petr Krause91f7a12017-12-14 20:57:36 +01002903 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002904 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2905 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2906 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2907 pCreateInfos[i].pColorBlendState,
2908 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2909 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2910
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002911 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002912 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002913 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2914 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002915 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2916 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002917 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2918 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002919
2920 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002921 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002922 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002923 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002924
2925 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002926 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002927 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2928 pCreateInfos[i].pColorBlendState->logicOpEnable);
2929
2930 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002931 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002932 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2933 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002934 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002935 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002936
2937 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002938 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2939 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002940 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002941 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002942 ParameterName::IndexVector{i, attachment_index}),
2943 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944
2945 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002946 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002947 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002948 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002949 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002950 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002951 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002952
2953 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002954 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002955 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002956 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002957 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002958 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002959 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002960
2961 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002962 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002963 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002964 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002966 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002967 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968
2969 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002970 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002971 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002972 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002974 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002975 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002976
2977 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002978 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002979 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002980 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002981 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002982 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002983 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002984
2985 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002986 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002988 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002990 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002991 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002992
2993 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002994 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002996 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002997 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002998 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002999 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000 }
3001 }
3002
3003 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003004 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003005 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
3006 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3007 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003008 }
3009
3010 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3011 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3012 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003013 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003014 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003015 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3016 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003017 }
3018 }
3019 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003020
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003021 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3022 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003023 if (pCreateInfos[i].basePipelineIndex != -1) {
3024 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003025 skip |=
3026 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003027 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003028 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003029 "and pCreateInfos->basePipelineIndex is not -1.",
3030 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003031 }
3032 }
3033
Petr Kraus9752aae2017-11-24 03:05:50 +01003034 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3035 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003036 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003037 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003038 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003039 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3040 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003041 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003042 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003043 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003044 skip |=
3045 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
3046 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
3047 "index into the pCreateInfos array, of size %d.",
3048 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003049 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003050 }
3051 }
3052
Petr Kraus9752aae2017-11-24 03:05:50 +01003053 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003054 if (!device_extensions.vk_nv_fill_rectangle) {
3055 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3056 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003057 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3058 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3059 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3060 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003061 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3062 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003063 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003064 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003065 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
3066 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3067 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003068 }
3069 } else {
3070 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3071 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3072 (physical_device_features.fillModeNonSolid == false)) {
3073 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003074 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3075 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003076 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
3077 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3078 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003079 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003080 }
Petr Kraus299ba622017-11-24 03:09:03 +01003081
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003082 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003083 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003084 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3085 "The line width state is static (pCreateInfos[%" PRIu32
3086 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3087 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3088 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3089 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003090 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003091 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003092
3093 // Validate no flags not allowed are used
3094 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003095 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
3096 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3097 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3098 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003099 }
3100 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003101 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
3102 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3103 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3104 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003105 }
3106 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3107 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07003108 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3109 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3110 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003111 }
3112 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3113 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07003114 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3115 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3116 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003117 }
3118 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3119 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07003120 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3121 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3122 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003123 }
3124 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3125 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003126 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3127 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3128 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003129 }
3130 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3131 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003132 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3133 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3134 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003135 }
3136 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3137 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003138 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3139 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3140 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003141 }
3142 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3143 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003144 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3145 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3146 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003147 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003148 }
3149 }
3150
3151 return skip;
3152}
3153
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003154bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3155 uint32_t createInfoCount,
3156 const VkComputePipelineCreateInfo *pCreateInfos,
3157 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003158 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003159 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003161 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003162 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003163 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003164 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003165 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003166 skip |=
3167 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3168 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3169 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3170 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003171 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003172
3173 // Make sure compute stage is selected
3174 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003175 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3176 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3177 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003178 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003179
sfricke-samsungeb549012021-04-16 01:25:51 -07003180 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3181 // Validate no flags not allowed are used
3182 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3183 skip |= LogError(
3184 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3185 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3186 i, flags);
3187 }
3188 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3189 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3190 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3191 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3192 i, flags);
3193 }
3194 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3195 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3196 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3197 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3198 i, flags);
3199 }
3200 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3201 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3202 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3203 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3204 i, flags);
3205 }
3206 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3207 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3208 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3209 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3210 i, flags);
3211 }
3212 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3213 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3214 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3215 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3216 i, flags);
3217 }
3218 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3219 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3220 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3221 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3222 i, flags);
3223 }
3224 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3225 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3226 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3227 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3228 i, flags);
3229 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003230 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3231 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
3232 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3233 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3234 i, flags);
3235 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003236 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3237 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3238 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3239 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3240 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003241 }
ziga-lunargc6341372021-07-28 12:57:42 +02003242
3243 std::stringstream msg;
3244 msg << "pCreateInfos[%" << i << "].stage";
3245 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003246 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003247 return skip;
3248}
3249
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003250bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003251 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003252 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003253
3254 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003255 const auto &features = physical_device_features;
3256 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003257
John Zulauf71968502017-10-26 13:51:15 -06003258 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3259 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003260 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3261 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3262 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3263 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003264 }
3265
3266 // Anistropy cannot be enabled in sampler unless enabled as a feature
3267 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003268 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3269 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3270 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003271 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003272 }
John Zulauf71968502017-10-26 13:51:15 -06003273
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003274 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3275 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003276 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3277 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3278 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3279 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003280 }
3281 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003282 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3283 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3284 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3285 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003286 }
3287 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003288 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3289 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3290 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3291 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003292 }
3293 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3294 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3295 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3296 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003297 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3298 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3299 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3300 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3301 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3302 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003303 }
3304 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003305 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3306 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3307 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003308 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003309 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003310 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3311 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3312 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003313 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003314 }
3315
3316 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3317 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003318 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3319 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003320 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003321 if (sampler_reduction != nullptr) {
3322 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3323 skip |= LogError(
3324 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3325 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3326 }
3327 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003328 }
3329
3330 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3331 // valid VkBorderColor value
3332 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3333 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3334 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003335 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3336 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003337 }
3338
John Zulauf275805c2017-10-26 15:34:49 -06003339 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003340 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003341 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3342 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003343 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3344 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3345 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003346 }
3347 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003348
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003349 // Check for valid Lod range
3350 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003351 skip |=
3352 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3353 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003354 }
3355
3356 // Check mipLodBias to device limit
3357 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003358 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3359 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3360 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003361 }
3362
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003363 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003364 if (sampler_conversion != nullptr) {
3365 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3366 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3367 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3368 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003369 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003370 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003371 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3372 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3373 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3374 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3375 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3376 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3377 }
3378 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003379
3380 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3381 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3382 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3383 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3384 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3385 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3386 }
3387 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3388 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3389 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3390 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3391 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3392 }
3393 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3394 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3395 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3396 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3397 pCreateInfo->minLod, pCreateInfo->maxLod);
3398 }
3399 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3400 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3401 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3402 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3403 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3404 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3405 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3406 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3407 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3408 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3409 }
3410 if (pCreateInfo->anisotropyEnable) {
3411 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3412 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3413 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3414 }
3415 if (pCreateInfo->compareEnable) {
3416 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3417 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3418 "pCreateInfo->compareEnable must be VK_FALSE");
3419 }
3420 if (pCreateInfo->unnormalizedCoordinates) {
3421 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3422 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3423 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3424 }
3425 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003426 }
3427
Tony-LunarG7337b312020-04-15 16:40:25 -06003428 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3429 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3430 if (!device_extensions.vk_ext_custom_border_color) {
3431 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3432 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3433 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3434 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003435 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003436 if (!custom_create_info) {
3437 skip |=
3438 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3439 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3440 "struct in pNext chain.\n",
3441 string_VkBorderColor(pCreateInfo->borderColor));
3442 } else {
3443 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3444 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3445 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3446 !FormatIsSampledFloat(custom_create_info->format)))) {
3447 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3448 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3449 "whose type does not match\n",
3450 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3451 ;
3452 }
3453 }
3454 }
3455
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003456 return skip;
3457}
3458
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003459bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3460 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3461 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003462 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003463 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003464
3465 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3466 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3467 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3468 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003469 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3470 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3471 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3472 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3473 ++descriptor_index) {
3474 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003475 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003476 "vkCreateDescriptorSetLayout: required parameter "
3477 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3478 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003479 }
3480 }
3481 }
3482
3483 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3484 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3485 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003486 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3487 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3488 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3489 "values.",
3490 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003491 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003492
3493 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3494 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3495 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3496 skip |=
3497 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3498 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3499 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3500 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3501 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3502 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003503 }
3504 }
3505 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003506 return skip;
3507}
3508
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003509bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3510 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003511 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003512 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3513 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3514 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003515 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3516 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003517}
3518
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003519bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3520 const VkWriteDescriptorSet *pDescriptorWrites,
3521 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003522 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003523
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003524 if (pDescriptorWrites != NULL) {
3525 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3526 // descriptorCount must be greater than 0
3527 if (pDescriptorWrites[i].descriptorCount == 0) {
3528 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003529 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3530 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003531 }
3532
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003533 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3534 if (validateDstSet) {
3535 // dstSet must be a valid VkDescriptorSet handle
3536 skip |= validate_required_handle(vkCallingFunction,
3537 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3538 pDescriptorWrites[i].dstSet);
3539 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003540
3541 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3542 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3543 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3544 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3545 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3546 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3547 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003548 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3549 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003550 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003551 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3552 "%s(): if pDescriptorWrites[%d].descriptorType is "
3553 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3554 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3555 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3556 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003557 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3558 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003559 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3560 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003561 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3562 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003563 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003564 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3565 ParameterName::IndexVector{i, descriptor_index}),
3566 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003567 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003568 }
3569 }
3570 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3571 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3572 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3573 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3574 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3575 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3576 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003577 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003578 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003579 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3580 "%s(): if pDescriptorWrites[%d].descriptorType is "
3581 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3582 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3583 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3584 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003585 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003586 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003587 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003588 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003589 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3590 ++descriptor_index) {
3591 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3592 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3593 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003594 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3595 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003596 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003597 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3598 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003599 }
3600 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003601 }
3602 }
3603 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3604 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003605 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003606 }
3607
3608 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3609 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003610 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003611 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3612 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003613 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003614 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003615 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3616 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3617 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003618 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003619 }
3620 }
3621 }
3622 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3623 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003624 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003625 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3626 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003627 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003628 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003629 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3630 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3631 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003632 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003633 }
3634 }
3635 }
3636 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003637 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3638 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003639 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003640 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003641 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3642 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3643 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3644 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3645 "accelerationStructureCount %d member equals descriptorCount %d.",
3646 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3647 pDescriptorWrites[i].descriptorCount);
3648 }
3649 // further checks only if we have right structtype
3650 if (pnext_struct) {
3651 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3652 skip |= LogError(
3653 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3654 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3655 ".",
3656 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003657 }
sourav parmarbcee7512020-12-28 14:34:49 -08003658 if (pnext_struct->accelerationStructureCount == 0) {
3659 skip |= LogError(device,
3660 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003661 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003662 }
3663 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003664 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003665 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3666 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3667 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3668 skip |= LogError(device,
3669 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3670 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003671 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003672 }
3673 }
3674 }
sourav parmarbcee7512020-12-28 14:34:49 -08003675 }
3676 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003677 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003678 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3679 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3680 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3681 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3682 "accelerationStructureCount %d member equals descriptorCount %d.",
3683 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3684 pDescriptorWrites[i].descriptorCount);
3685 }
3686 // further checks only if we have right structtype
3687 if (pnext_struct) {
3688 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3689 skip |= LogError(
3690 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3691 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3692 ".",
3693 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003694 }
sourav parmarbcee7512020-12-28 14:34:49 -08003695 if (pnext_struct->accelerationStructureCount == 0) {
3696 skip |= LogError(device,
3697 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003698 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003699 }
3700 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003701 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003702 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3703 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3704 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3705 skip |= LogError(device,
3706 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3707 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003708 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003709 }
3710 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003711 }
3712 }
3713 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003714 }
3715 }
3716 return skip;
3717}
3718
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003719bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3720 const VkWriteDescriptorSet *pDescriptorWrites,
3721 uint32_t descriptorCopyCount,
3722 const VkCopyDescriptorSet *pDescriptorCopies) const {
3723 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3724}
3725
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003726bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003727 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003728 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003729 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3730}
3731
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003732bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3733 const VkAllocationCallbacks *pAllocator,
3734 VkRenderPass *pRenderPass) const {
3735 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3736}
3737
Mike Schuchardt2df08912020-12-15 16:28:09 -08003738bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003739 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003740 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003741 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3742}
3743
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003744bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3745 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003746 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003747 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003748
3749 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3750 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3751 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003752 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3753 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003754 return skip;
3755}
3756
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003757bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003758 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003759 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003760
3761 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3762 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003763 bool cb_is_secondary;
3764 {
3765 auto lock = cb_read_lock();
3766 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3767 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003768
Tony-LunarG3c287f62020-12-17 12:39:49 -07003769 if (cb_is_secondary) {
3770 // Implicit VUs
3771 // validate only sType here; pointer has to be validated in core_validation
3772 const bool k_not_required = false;
3773 const char *k_no_vuid = nullptr;
3774 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3775 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003776 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3777 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003778
Tony-LunarG3c287f62020-12-17 12:39:49 -07003779 if (info) {
3780 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003781 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3782 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003783 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003784 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3785 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3786 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3787 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003788
Tony-LunarG3c287f62020-12-17 12:39:49 -07003789 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003790
Tony-LunarG3c287f62020-12-17 12:39:49 -07003791 // Explicit VUs
3792 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003793 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003794 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3795 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3796 cmd_name);
3797 }
3798
3799 if (physical_device_features.inheritedQueries) {
3800 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003801 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3802 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3803 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003804 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003805 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003806 }
3807
3808 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003809 skip |=
3810 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3811 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3812 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3813 } else { // !pipelineStatisticsQuery
3814 skip |=
3815 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3816 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003817 }
3818
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003819 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003820 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003821 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003822 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3823 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3824 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003825 commandBuffer,
3826 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003827 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3828 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3829 }
Petr Kraus139757b2019-08-15 17:19:33 +02003830 }
ziga-lunarg9d019132021-07-19 01:05:31 +02003831
3832 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
3833 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
3834 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
3835 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
3836 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
3837 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
3838 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
3839 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
3840 }
Petr Kraus139757b2019-08-15 17:19:33 +02003841 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003842 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003843 return skip;
3844}
3845
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003846bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003847 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003848 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003849
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003850 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003851 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003852 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3853 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3854 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003855 }
3856 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003857 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3858 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3859 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003860 }
3861 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003862 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003863 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003864 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3865 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3866 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3867 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003868 }
3869 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003870
3871 if (pViewports) {
3872 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3873 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003874 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003875 skip |= manual_PreCallValidateViewport(
3876 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003877 }
3878 }
3879
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003880 return skip;
3881}
3882
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003883bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003884 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003885 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003886
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003887 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003888 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003889 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3890 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3891 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003892 }
3893 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003894 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3895 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3896 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003897 }
3898 } else { // multiViewport enabled
3899 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003900 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003901 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3902 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3903 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3904 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003905 }
3906 }
3907
Petr Kraus6260f0a2018-02-27 21:15:55 +01003908 if (pScissors) {
3909 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3910 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003911
Petr Kraus6260f0a2018-02-27 21:15:55 +01003912 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003913 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3914 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3915 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003916 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003917
Petr Kraus6260f0a2018-02-27 21:15:55 +01003918 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003919 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3920 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3921 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003922 }
3923
3924 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3925 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003926 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3927 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3928 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3929 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003930 }
3931
3932 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3933 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003934 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3935 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3936 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3937 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003938 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003939 }
3940 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003941
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003942 return skip;
3943}
3944
Jeff Bolz5c801d12019-10-09 10:38:45 -05003945bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003946 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003947
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003948 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003949 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3950 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003951 }
3952
3953 return skip;
3954}
3955
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003956bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003957 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003958 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003959
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003960 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003961 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003962 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3963 }
3964 if (drawCount > device_limits.maxDrawIndirectCount) {
3965 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003966 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3967 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003968 }
3969 return skip;
3970}
3971
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003972bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003973 VkDeviceSize offset, uint32_t drawCount,
3974 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003975 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003976 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003977 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3978 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3979 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003980 }
3981 if (drawCount > device_limits.maxDrawIndirectCount) {
3982 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003983 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3984 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003985 }
3986 return skip;
3987}
3988
sfricke-samsungf692b972020-05-02 08:00:45 -07003989bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3990 VkDeviceSize countBufferOffset, bool khr) const {
3991 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003992 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003993 if (offset & 3) {
3994 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003995 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003996 }
3997
3998 if (countBufferOffset & 3) {
3999 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004000 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004001 countBufferOffset);
4002 }
4003 return skip;
4004}
4005
4006bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4007 VkDeviceSize offset, VkBuffer countBuffer,
4008 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4009 uint32_t stride) const {
4010 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4011}
4012
4013bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(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, true);
4018}
4019
4020bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4021 VkDeviceSize countBufferOffset, bool khr) const {
4022 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004023 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004024 if (offset & 3) {
4025 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004026 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004027 }
4028
4029 if (countBufferOffset & 3) {
4030 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004031 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004032 countBufferOffset);
4033 }
4034 return skip;
4035}
4036
4037bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4038 VkDeviceSize offset, VkBuffer countBuffer,
4039 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4040 uint32_t stride) const {
4041 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4042}
4043
4044bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4045 VkDeviceSize offset, VkBuffer countBuffer,
4046 VkDeviceSize countBufferOffset,
4047 uint32_t maxDrawCount, uint32_t stride) const {
4048 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4049}
4050
Tony-LunarG4490de42021-06-21 15:49:19 -06004051bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4052 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4053 uint32_t firstInstance, uint32_t stride) const {
4054 bool skip = false;
4055 if (stride & 3) {
4056 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4057 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4058 }
4059 if (drawCount && nullptr == pVertexInfo) {
4060 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4061 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4062 "one or more valid instances of VkMultiDrawInfoEXT structures");
4063 }
4064 return skip;
4065}
4066
4067bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4068 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4069 uint32_t instanceCount, uint32_t firstInstance,
4070 uint32_t stride, const int32_t *pVertexOffset) const {
4071 bool skip = false;
4072 if (stride & 3) {
4073 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4074 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4075 }
4076 if (drawCount && nullptr == pIndexInfo) {
4077 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4078 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4079 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4080 }
4081 return skip;
4082}
4083
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004084bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4085 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004086 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004087 bool skip = false;
4088 for (uint32_t rect = 0; rect < rectCount; rect++) {
4089 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004090 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
4091 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004092 }
sfricke-samsung10867682020-04-25 02:20:39 -07004093 if (pRects[rect].rect.extent.width == 0) {
4094 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
4095 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
4096 }
4097 if (pRects[rect].rect.extent.height == 0) {
4098 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
4099 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
4100 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004101 }
4102 return skip;
4103}
4104
Andrew Fobel3abeb992020-01-20 16:33:22 -05004105bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4106 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4107 VkImageFormatProperties2 *pImageFormatProperties,
4108 const char *apiName) const {
4109 bool skip = false;
4110
4111 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004112 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004113 if (image_stencil_struct != nullptr) {
4114 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4115 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4116 // No flags other than the legal attachment bits may be set
4117 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4118 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004119 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4120 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4121 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4122 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4123 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004124 }
4125 }
4126 }
4127 }
4128
4129 return skip;
4130}
4131
4132bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4133 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4134 VkImageFormatProperties2 *pImageFormatProperties) const {
4135 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4136 "vkGetPhysicalDeviceImageFormatProperties2");
4137}
4138
4139bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4140 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4141 VkImageFormatProperties2 *pImageFormatProperties) const {
4142 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4143 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4144}
4145
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004146bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4147 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4148 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4149 bool skip = false;
4150
4151 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4152 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4153 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4154 }
4155
4156 return skip;
4157}
4158
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004159bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4160 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4161 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4162 bool skip = false;
4163
4164 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4165 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4166 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4167 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4168 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4169 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4170 }
4171
4172 return false;
4173}
4174
sfricke-samsung3999ef62020-02-09 17:05:59 -08004175bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4176 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4177 bool skip = false;
4178
4179 if (pRegions != nullptr) {
4180 for (uint32_t i = 0; i < regionCount; i++) {
4181 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004182 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4183 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004184 }
4185 }
4186 }
4187 return skip;
4188}
4189
Jeff Leger178b1e52020-10-05 12:22:23 -04004190bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4191 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4192 bool skip = false;
4193
4194 if (pCopyBufferInfo->pRegions != nullptr) {
4195 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4196 if (pCopyBufferInfo->pRegions[i].size == 0) {
4197 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4198 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4199 }
4200 }
4201 }
4202 return skip;
4203}
4204
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004205bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004206 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4207 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004208 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004209
4210 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004211 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4212 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4213 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004214 }
4215
4216 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004217 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4218 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4219 "), must be greater than zero and less than or equal to 65536.",
4220 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004221 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004222 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4223 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4224 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004225 }
4226 return skip;
4227}
4228
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004229bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004230 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004231 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004232
4233 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004234 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4235 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4236 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004237 }
4238
4239 if (size != VK_WHOLE_SIZE) {
4240 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004241 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004242 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4243 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004244 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004245 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4246 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004247 }
4248 }
4249 return skip;
4250}
4251
sfricke-samsunga1d00272021-03-10 21:37:41 -08004252bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004253 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004254
4255 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004256 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4257 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4258 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4259 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004260 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004261 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4262 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4263 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004264 }
4265
4266 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4267 // queueFamilyIndexCount uint32_t values
4268 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004269 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004270 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004271 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004272 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4273 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004274 }
4275 }
4276
Dave Houlton413a6782018-05-22 13:01:54 -06004277 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004278 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004279
sfricke-samsunga1d00272021-03-10 21:37:41 -08004280 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4281 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4282 if (format_list_info) {
4283 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4284 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4285 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4286 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4287 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4288 func_name, viewFormatCount);
4289 }
4290
4291 // Using the first format, compare the rest of the formats against it that they are compatible
4292 for (uint32_t i = 1; i < viewFormatCount; i++) {
4293 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4294 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4295 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4296 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4297 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4298 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4299 string_VkFormat(format_list_info->pViewFormats[i]));
4300 }
4301 }
4302 }
4303
4304 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4305 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4306 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4307 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4308 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4309 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4310 func_name);
4311 } else {
4312 if (format_list_info == nullptr) {
4313 skip |= LogError(
4314 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4315 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4316 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4317 func_name);
4318 } else if (format_list_info->viewFormatCount == 0) {
4319 skip |= LogError(
4320 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4321 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4322 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4323 func_name);
4324 } else {
4325 bool found_base_format = false;
4326 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4327 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4328 found_base_format = true;
4329 break;
4330 }
4331 }
4332 if (!found_base_format) {
4333 skip |=
4334 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4335 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4336 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4337 "pCreateInfo->imageFormat.",
4338 func_name);
4339 }
4340 }
4341 }
4342 }
4343 }
4344 return skip;
4345}
4346
4347bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4348 const VkAllocationCallbacks *pAllocator,
4349 VkSwapchainKHR *pSwapchain) const {
4350 bool skip = false;
4351 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4352 return skip;
4353}
4354
4355bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4356 const VkSwapchainCreateInfoKHR *pCreateInfos,
4357 const VkAllocationCallbacks *pAllocator,
4358 VkSwapchainKHR *pSwapchains) const {
4359 bool skip = false;
4360 if (pCreateInfos) {
4361 for (uint32_t i = 0; i < swapchainCount; i++) {
4362 std::stringstream func_name;
4363 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4364 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4365 }
4366 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004367 return skip;
4368}
4369
Jeff Bolz5c801d12019-10-09 10:38:45 -05004370bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004371 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004372
4373 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004374 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004375 if (present_regions) {
4376 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004377 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004378 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4379 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004380 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004381 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4382 "extension swapchainCount is %i. These values must be equal.",
4383 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004384 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004385 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004386 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4387 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004388 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4389 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4390 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004391 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004392 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004393 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004394 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004395 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004396 }
4397 }
4398
4399 return skip;
4400}
4401
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004402bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4403 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4404 const VkAllocationCallbacks *pAllocator,
4405 VkDisplayModeKHR *pMode) const {
4406 bool skip = false;
4407
4408 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4409 if (display_mode_parameters.visibleRegion.width == 0) {
4410 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4411 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4412 }
4413 if (display_mode_parameters.visibleRegion.height == 0) {
4414 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4415 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4416 }
4417 if (display_mode_parameters.refreshRate == 0) {
4418 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4419 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4420 }
4421
4422 return skip;
4423}
4424
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004425#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004426bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4427 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4428 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004429 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004430 bool skip = false;
4431
4432 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004433 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4434 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004435 }
4436
4437 return skip;
4438}
4439#endif // VK_USE_PLATFORM_WIN32_KHR
4440
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004441bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004442 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004443 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004444 bool skip = false;
4445
4446 if (pCreateInfo) {
4447 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004448 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4449 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004450 }
4451
4452 if (pCreateInfo->pPoolSizes) {
4453 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4454 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004455 skip |= LogError(
4456 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004457 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004458 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004459 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4460 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004461 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4462 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4463 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4464 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4465 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004466 }
Petr Krausc8655be2017-09-27 18:56:51 +02004467 }
4468 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004469
4470 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4471 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4472 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4473 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4474 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4475 }
Petr Krausc8655be2017-09-27 18:56:51 +02004476 }
4477
4478 return skip;
4479}
4480
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004481bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004482 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004483 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004484
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004485 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004486 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004487 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4488 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4489 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004490 }
4491
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004492 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004493 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004494 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4495 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4496 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004497 }
4498
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004499 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004500 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004501 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4502 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4503 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004504 }
4505
4506 return skip;
4507}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004508
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004509bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004510 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004511 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004512
4513 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004514 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4515 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004516 }
4517 return skip;
4518}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004519
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004520bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4521 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004522 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004523 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004524
4525 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004526 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004527 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004528 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4529 "vkCmdDispatch(): baseGroupX (%" PRIu32
4530 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4531 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004532 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004533 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4534 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4535 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4536 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004537 }
4538
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004539 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004540 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004541 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4542 "vkCmdDispatch(): baseGroupY (%" PRIu32
4543 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4544 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004545 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004546 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4547 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4548 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4549 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004550 }
4551
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004552 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004553 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004554 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4555 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4556 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4557 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004558 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004559 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4560 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4561 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4562 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004563 }
4564
4565 return skip;
4566}
4567
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004568bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4569 VkPipelineBindPoint pipelineBindPoint,
4570 VkPipelineLayout layout, uint32_t set,
4571 uint32_t descriptorWriteCount,
4572 const VkWriteDescriptorSet *pDescriptorWrites) const {
4573 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4574}
4575
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004576bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4577 uint32_t firstExclusiveScissor,
4578 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004579 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004580 bool skip = false;
4581
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004582 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004583 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004584 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004585 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4586 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4587 ") is not 0.",
4588 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004589 }
4590 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004591 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004592 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4593 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4594 ") is not 1.",
4595 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004596 }
4597 } else { // multiViewport enabled
4598 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004599 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004600 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4601 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4602 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4603 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004604 }
4605 }
4606
Jeff Bolz3e71f782018-08-29 23:15:45 -05004607 if (pExclusiveScissors) {
4608 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4609 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4610
4611 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004612 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4613 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4614 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004615 }
4616
4617 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004618 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4619 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4620 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004621 }
4622
4623 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4624 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004625 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4626 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4627 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4628 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004629 }
4630
4631 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4632 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004633 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4634 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4635 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4636 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004637 }
4638 }
4639 }
4640
4641 return skip;
4642}
4643
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004644bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4645 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004646 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004647 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004648 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4649 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4650 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4651 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4652 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4653 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004654 }
4655
4656 return skip;
4657}
4658
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004659bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4660 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004661 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004662 bool skip = false;
4663
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004664 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004665 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004666 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004667 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4668 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4669 ") is not 0.",
4670 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004671 }
4672 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004673 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004674 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4675 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4676 ") is not 1.",
4677 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004678 }
4679 }
4680
Jeff Bolz9af91c52018-09-01 21:53:57 -05004681 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004682 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004683 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4684 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4685 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4686 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004687 }
4688
4689 return skip;
4690}
4691
Jeff Bolz5c801d12019-10-09 10:38:45 -05004692bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4693 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4694 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004695 bool skip = false;
4696
Dave Houlton142c4cb2018-10-17 15:04:41 -06004697 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004698 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4699 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4700 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004701 }
4702
4703 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004704 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004705 }
4706
4707 return skip;
4708}
4709
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004710bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004711 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004712 bool skip = false;
4713
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004714 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004715 skip |= LogError(
4716 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004717 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4718 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004719 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004720 }
4721
4722 return skip;
4723}
4724
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004725bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4726 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004727 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004728 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004729 static const int condition_multiples = 0b0011;
4730 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004731 skip |= LogError(
4732 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004733 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004734 }
Lockee1c22882019-06-10 16:02:54 -06004735 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004736 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4737 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4738 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4739 stride);
Lockee1c22882019-06-10 16:02:54 -06004740 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004741 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004742 skip |= LogError(
4743 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4744 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004745 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004746 if (drawCount > device_limits.maxDrawIndirectCount) {
4747 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004748 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4749 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004750 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004751 return skip;
4752}
4753
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004754bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4755 VkDeviceSize offset, VkBuffer countBuffer,
4756 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004757 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004758 bool skip = false;
4759
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004760 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004761 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4762 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4763 "), is not a multiple of 4.",
4764 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004765 }
4766
4767 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004768 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4769 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4770 "), is not a multiple of 4.",
4771 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004772 }
4773
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004774 return skip;
4775}
4776
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004777bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004778 const VkAllocationCallbacks *pAllocator,
4779 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004780 bool skip = false;
4781
4782 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4783 if (pCreateInfo != nullptr) {
4784 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4785 // VkQueryPipelineStatisticFlagBits values
4786 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4787 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004788 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4789 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4790 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4791 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004792 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004793 if (pCreateInfo->queryCount == 0) {
4794 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4795 "vkCreateQueryPool(): queryCount must be greater than zero.");
4796 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004797 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004798 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004799}
4800
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004801bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4802 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004803 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004804 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4805 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004806}
4807
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004808void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004809 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4810 VkResult result) {
4811 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004812 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004813}
4814
Mike Schuchardt2df08912020-12-15 16:28:09 -08004815void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004816 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4817 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004818 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004819 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004820 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004821}
4822
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004823void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4824 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004825 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004826 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004827 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004828}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004829
Tony-LunarG3c287f62020-12-17 12:39:49 -07004830void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004831 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004832 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4833 auto lock = cb_write_lock();
4834 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004835 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004836 }
4837 }
4838}
4839
4840void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004841 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004842 auto lock = cb_write_lock();
4843 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4844 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4845 }
4846}
4847
4848void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004849 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004850 auto lock = cb_write_lock();
4851 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4852 if (item->second == commandPool) {
4853 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004854 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004855 ++item;
4856 }
4857 }
4858}
4859
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004860bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004861 const VkAllocationCallbacks *pAllocator,
4862 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004863 bool skip = false;
4864
4865 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004866 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004867 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004868 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4869 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004870 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004871
4872 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004873 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004874 if (flags_info) {
4875 flags = flags_info->flags;
4876 }
4877
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004878 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004879 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004880 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004881 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4882 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004883 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004884 }
4885
4886#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004887 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004888#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004889 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4890 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004891#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004892 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004893#endif
4894
4895 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004896 skip |= LogError(
4897 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004898 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4899 }
4900 if (
4901#ifdef VK_USE_PLATFORM_WIN32_KHR
4902 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4903#endif
4904 (import_memory_fd && import_memory_fd->handleType) ||
4905#ifdef VK_USE_PLATFORM_ANDROID_KHR
4906 (import_memory_ahb && import_memory_ahb->buffer) ||
4907#endif
4908 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004909 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4910 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004911 }
4912 }
4913
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02004914 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
4915 if (export_memory) {
4916 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
4917 if (export_memory_nv) {
4918 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4919 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4920 "VkExportMemoryAllocateInfoNV");
4921 }
4922#ifdef VK_USE_PLATFORM_WIN32_KHR
4923 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
4924 if (export_memory_win32_nv) {
4925 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4926 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4927 "VkExportMemoryWin32HandleInfoNV");
4928 }
4929#endif
4930 }
4931
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004932 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004933 VkBool32 capture_replay = false;
4934 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004935 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004936 if (vulkan_12_features) {
4937 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4938 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4939 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004940 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004941 if (bda_features) {
4942 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4943 buffer_device_address = bda_features->bufferDeviceAddress;
4944 }
4945 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004946 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004947 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004948 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004949 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004950 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004951 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004952 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004953 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004954 }
4955 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004956 }
4957 return skip;
4958}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004959
Jason Macnak192fa0e2019-07-26 15:07:16 -07004960bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004961 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004962 bool skip = false;
4963
4964 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4965 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4966 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004967 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004968 } else {
4969 uint32_t vertex_component_size = 0;
4970 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4971 vertex_component_size = 4;
4972 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4973 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4974 vertex_component_size = 2;
4975 }
4976 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004977 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004978 }
4979 }
4980
4981 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4982 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004983 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004984 } else {
4985 uint32_t index_element_size = 0;
4986 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4987 index_element_size = 4;
4988 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4989 index_element_size = 2;
4990 }
4991 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004992 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004993 }
4994 }
4995 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4996 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004997 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004998 }
4999 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005000 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005001 }
5002 }
5003
5004 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005005 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005006 }
5007
5008 return skip;
5009}
5010
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005011bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5012 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005013 bool skip = false;
5014
5015 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005016 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005017 }
5018 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005019 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005020 }
5021
5022 return skip;
5023}
5024
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005025bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5026 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005027 bool skip = false;
5028 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005029 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005030 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005031 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005032 }
5033 return skip;
5034}
5035
5036bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005037 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005038 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005039 bool skip = false;
5040 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005041 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5042 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5043 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005044 }
5045 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005046 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5047 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5048 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005049 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005050 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5051 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5052 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5053 }
Jason Macnak5c954952019-07-09 15:46:12 -07005054 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5055 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005056 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5057 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5058 "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 -07005059 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005060 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005061 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005062 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5063 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005064 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5065 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005066 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005067 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005068 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5069 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5070 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005071 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005072 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005073 uint64_t total_triangle_count = 0;
5074 for (uint32_t i = 0; i < info.geometryCount; i++) {
5075 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005076
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005077 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005078
Jason Macnak5c954952019-07-09 15:46:12 -07005079 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5080 continue;
5081 }
5082 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5083 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005084 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005085 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5086 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5087 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005088 }
5089 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005090 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5091 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5092 for (uint32_t i = 1; i < info.geometryCount; i++) {
5093 const VkGeometryNV &geometry = info.pGeometries[i];
5094 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005095 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005096 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
5097 "info.pGeometries[0].geometryType.",
5098 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005099 }
5100 }
5101 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005102 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5103 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5104 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5105 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5106 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5107 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5108 }
5109 }
5110 skip |=
5111 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005112 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005113 return skip;
5114}
5115
Ricardo Garciaa4935972019-02-21 17:43:18 +01005116bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5117 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005118 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005119 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005120 if (pCreateInfo) {
5121 if ((pCreateInfo->compactedSize != 0) &&
5122 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005123 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5124 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5125 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5126 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005127 }
Jason Macnak5c954952019-07-09 15:46:12 -07005128
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005129 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005130 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005131 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005132 return skip;
5133}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005134
Jeff Bolz5c801d12019-10-09 10:38:45 -05005135bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5136 const VkAccelerationStructureInfoNV *pInfo,
5137 VkBuffer instanceData, VkDeviceSize instanceOffset,
5138 VkBool32 update, VkAccelerationStructureNV dst,
5139 VkAccelerationStructureNV src, VkBuffer scratch,
5140 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005141 bool skip = false;
5142
5143 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005144 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005145 }
5146
5147 return skip;
5148}
5149
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005150bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5151 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5152 VkAccelerationStructureKHR *pAccelerationStructure) const {
5153 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005154 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005155 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005156 if (!acceleration_structure_features ||
5157 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5158 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5159 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5160 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005161 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005162 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5163 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005164 (acceleration_structure_features &&
5165 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005166 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005167 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5168 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5169 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5170 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005171 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005172 if (pCreateInfo->deviceAddress &&
5173 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5174 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5175 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5176 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5177 }
5178 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5179 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005180 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005181 }
sourav parmar83c31b12020-05-06 12:30:54 -07005182 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005183 return skip;
5184}
5185
Jason Macnak5c954952019-07-09 15:46:12 -07005186bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5187 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005188 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005189 bool skip = false;
5190 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005191 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5192 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005193 }
5194 return skip;
5195}
5196
sourav parmarcd5fb182020-07-17 12:58:44 -07005197bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5198 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5199 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5200 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005201 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005202 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
5203 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005204 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005205 }
5206 return skip;
5207}
5208
Peter Chen85366392019-05-14 15:20:11 -04005209bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5210 uint32_t createInfoCount,
5211 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5212 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005213 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005214 bool skip = false;
5215
5216 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005217 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5218 std::stringstream msg;
5219 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5220 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5221 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005222 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005223 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005224 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005225 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5226 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5227 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5228 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005229 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005230
5231 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005232 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005233 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5234 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5235 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5236 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5237 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5238 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5239 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5240 }
5241 }
5242
sourav parmarf4a78252020-04-10 13:04:21 -07005243 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5244 skip |=
5245 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5246 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5247 }
5248 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5249 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5250 skip |=
5251 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5252 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5253 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5254 }
5255 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5256 if (pCreateInfos[i].basePipelineIndex != -1) {
5257 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5258 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5259 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5260 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5261 "and pCreateInfos->basePipelineIndex is not -1.");
5262 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005263 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005264 skip |=
5265 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5266 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5267 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5268 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5269 "that element.");
5270 }
sourav parmarf4a78252020-04-10 13:04:21 -07005271 }
5272 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005273 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005274 skip |=
5275 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5276 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5277 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5278 "commands pCreateInfos parameter.");
5279 }
5280 } else {
5281 if (pCreateInfos[i].basePipelineIndex != -1) {
5282 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5283 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5284 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5285 }
5286 }
5287 }
5288 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5289 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5290 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5291 }
5292 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5293 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5294 "vkCreateRayTracingPipelinesNV: flags must not include "
5295 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5296 }
5297 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5298 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5299 "vkCreateRayTracingPipelinesNV: flags must not include "
5300 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5301 }
5302 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5303 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5304 "vkCreateRayTracingPipelinesNV: flags must not include "
5305 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5306 }
5307 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5308 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5309 "vkCreateRayTracingPipelinesNV: flags must not include "
5310 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5311 }
5312 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5313 skip |= LogError(
5314 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5315 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5316 }
5317 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5318 skip |= LogError(
5319 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5320 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5321 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005322 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5323 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5324 "vkCreateRayTracingPipelinesNV: flags must not include "
5325 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5326 }
5327 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5328 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5329 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5330 }
Peter Chen85366392019-05-14 15:20:11 -04005331 }
5332
5333 return skip;
5334}
5335
sourav parmarcd5fb182020-07-17 12:58:44 -07005336bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5337 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5338 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005339 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005340 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005341 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5342 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5343 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005344 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005345 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005346 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5347 std::stringstream msg;
5348 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5349 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5350 &pCreateInfos[i].pStages[i]);
5351 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005352 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5353 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5354 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5355 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5356 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5357 }
5358 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5359 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5360 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5361 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5362 }
5363 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005364 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005365 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5366 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005367 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5368 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5369 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005370 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5371 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5372 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005373 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005374 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005375 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5376 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5377 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5378 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005379 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005380 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5381 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5382 }
5383 }
sourav parmarf4a78252020-04-10 13:04:21 -07005384 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005385 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5386 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005387 }
5388 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005389 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005390 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005391 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5392 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005393 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005394 }
5395 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5396 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5397 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005398 }
5399 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5400 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5401 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5402 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5403 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5404 skip |= LogError(
5405 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005406 "vkCreateRayTracingPipelinesKHR: If flags includes "
5407 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005408 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5409 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5410 "must not be VK_SHADER_UNUSED_KHR");
5411 }
5412 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5413 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5414 skip |= LogError(
5415 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005416 "vkCreateRayTracingPipelinesKHR: If flags includes "
5417 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005418 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5419 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5420 "element must not be VK_SHADER_UNUSED_KHR");
5421 }
5422 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005423 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5424 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5425 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5426 skip |= LogError(
5427 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5428 "vkCreateRayTracingPipelinesKHR: If "
5429 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5430 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5431 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5432 }
5433 }
sourav parmarf4a78252020-04-10 13:04:21 -07005434 }
5435 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5436 if (pCreateInfos[i].basePipelineIndex != -1) {
5437 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5438 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005439 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005440 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5441 "and pCreateInfos->basePipelineIndex is not -1.");
5442 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005443 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005444 skip |=
5445 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5446 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5447 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5448 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5449 "element.");
5450 }
sourav parmarf4a78252020-04-10 13:04:21 -07005451 }
5452 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005453 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005454 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005455 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005456 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5457 "commands pCreateInfos parameter %d.",
5458 pCreateInfos[i].basePipelineIndex, createInfoCount);
5459 }
5460 } else {
5461 if (pCreateInfos[i].basePipelineIndex != -1) {
5462 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005463 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005464 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5465 }
5466 }
5467 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005468 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5469 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5470 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5471 "vkCreateRayTracingPipelinesKHR: If flags includes "
5472 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5473 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005474 }
5475 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5476 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5477 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5478 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5479 "pLibraryInfo and pLibraryInterface must be NULL.");
5480 }
5481 if (pCreateInfos[i].pLibraryInfo) {
5482 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5483 if (pCreateInfos[i].stageCount == 0) {
5484 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5485 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5486 "stageCount must not be 0.");
5487 }
5488 if (pCreateInfos[i].groupCount == 0) {
5489 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5490 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5491 "groupCount must not be 0.");
5492 }
5493 } else {
5494 if (pCreateInfos[i].pLibraryInterface == NULL) {
5495 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5496 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5497 "is greater than 0, its "
5498 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005499 }
5500 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005501 }
5502 if (pCreateInfos[i].pLibraryInterface) {
5503 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5504 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5505 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5506 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5507 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5508 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005509 }
5510 if (deferredOperation != VK_NULL_HANDLE) {
5511 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5512 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5513 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5514 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005515 }
5516 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005517 }
5518
5519 return skip;
5520}
5521
Mike Schuchardt21638df2019-03-16 10:52:02 -07005522#ifdef VK_USE_PLATFORM_WIN32_KHR
5523bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5524 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005525 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005526 bool skip = false;
5527 if (!device_extensions.vk_khr_swapchain)
5528 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005529 if (!device_extensions.vk_khr_get_surface_capabilities2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005530 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5531 if (!device_extensions.vk_khr_surface)
5532 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005533 if (!device_extensions.vk_khr_get_physical_device_properties2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005534 skip |=
5535 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5536 if (!device_extensions.vk_ext_full_screen_exclusive)
5537 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5538 skip |= validate_struct_type(
5539 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5540 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5541 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5542 if (pSurfaceInfo != NULL) {
5543 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5544 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5545 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5546
5547 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5548 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5549 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5550 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005551 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5552 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005553
5554 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5555 }
5556 return skip;
5557}
5558#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005559
5560bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5561 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005562 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005563 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5564 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005565 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005566 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5567 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5568 }
5569 return skip;
5570}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005571
5572bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005573 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005574 bool skip = false;
5575
5576 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005577 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5578 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005579 }
5580
5581 return skip;
5582}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005583
5584bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005585 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005586 bool skip = false;
5587
5588 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005589 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5590 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005591 }
5592
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005593 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005594 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005595 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5596 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005597 }
5598
5599 return skip;
5600}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005601
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005602bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5603 uint32_t bindingCount, const VkBuffer *pBuffers,
5604 const VkDeviceSize *pOffsets) const {
5605 bool skip = false;
5606 if (firstBinding > device_limits.maxVertexInputBindings) {
5607 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5608 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5609 device_limits.maxVertexInputBindings);
5610 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5611 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5612 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5613 "maxVertexInputBindings (%u)",
5614 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5615 }
5616
Jeff Bolz165818a2020-05-08 11:19:03 -05005617 for (uint32_t i = 0; i < bindingCount; ++i) {
5618 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005619 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005620 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5621 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5622 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5623 } else {
5624 if (pOffsets[i] != 0) {
5625 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5626 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5627 }
5628 }
5629 }
5630 }
5631
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005632 return skip;
5633}
5634
Mark Lobodzinski84988402019-09-11 15:27:30 -06005635bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005636 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005637 bool skip = false;
5638 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005639 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5640 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005641 }
5642 return skip;
5643}
5644
5645bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005646 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005647 bool skip = false;
5648 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005649 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5650 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005651 }
5652 return skip;
5653}
Petr Kraus3d720392019-11-13 02:52:39 +01005654
5655bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5656 VkSemaphore semaphore, VkFence fence,
5657 uint32_t *pImageIndex) const {
5658 bool skip = false;
5659
5660 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005661 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5662 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005663 }
5664
5665 return skip;
5666}
5667
5668bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5669 uint32_t *pImageIndex) const {
5670 bool skip = false;
5671
5672 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005673 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5674 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005675 }
5676
5677 return skip;
5678}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005679
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005680bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5681 uint32_t firstBinding, uint32_t bindingCount,
5682 const VkBuffer *pBuffers,
5683 const VkDeviceSize *pOffsets,
5684 const VkDeviceSize *pSizes) const {
5685 bool skip = false;
5686
5687 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5688 for (uint32_t i = 0; i < bindingCount; ++i) {
5689 if (pOffsets[i] & 3) {
5690 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5691 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5692 }
5693 }
5694
5695 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5696 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5697 "%s: The firstBinding(%" PRIu32
5698 ") index is greater than or equal to "
5699 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5700 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5701 }
5702
5703 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5704 skip |=
5705 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5706 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5707 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5708 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5709 }
5710
5711 for (uint32_t i = 0; i < bindingCount; ++i) {
5712 // pSizes is optional and may be nullptr.
5713 if (pSizes != nullptr) {
5714 if (pSizes[i] != VK_WHOLE_SIZE &&
5715 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5716 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5717 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5718 ") is not VK_WHOLE_SIZE and is greater than "
5719 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5720 cmd_name, i, pSizes[i]);
5721 }
5722 }
5723 }
5724
5725 return skip;
5726}
5727
5728bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5729 uint32_t firstCounterBuffer,
5730 uint32_t counterBufferCount,
5731 const VkBuffer *pCounterBuffers,
5732 const VkDeviceSize *pCounterBufferOffsets) const {
5733 bool skip = false;
5734
5735 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5736 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5737 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5738 "%s: The firstCounterBuffer(%" PRIu32
5739 ") index is greater than or equal to "
5740 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5741 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5742 }
5743
5744 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5745 skip |=
5746 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5747 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5748 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5749 cmd_name, firstCounterBuffer, counterBufferCount,
5750 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5751 }
5752
5753 return skip;
5754}
5755
5756bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5757 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5758 const VkBuffer *pCounterBuffers,
5759 const VkDeviceSize *pCounterBufferOffsets) const {
5760 bool skip = false;
5761
5762 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5763 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5764 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5765 "%s: The firstCounterBuffer(%" PRIu32
5766 ") index is greater than or equal to "
5767 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5768 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5769 }
5770
5771 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5772 skip |=
5773 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5774 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5775 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5776 cmd_name, firstCounterBuffer, counterBufferCount,
5777 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5778 }
5779
5780 return skip;
5781}
5782
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005783bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5784 uint32_t firstInstance, VkBuffer counterBuffer,
5785 VkDeviceSize counterBufferOffset,
5786 uint32_t counterOffset, uint32_t vertexStride) const {
5787 bool skip = false;
5788
5789 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005790 skip |= LogError(
5791 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005792 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5793 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5794 }
5795
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005796 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005797 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005798 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005799 }
5800
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005801 return skip;
5802}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005803
5804bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5805 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5806 const VkAllocationCallbacks *pAllocator,
5807 VkSamplerYcbcrConversion *pYcbcrConversion,
5808 const char *apiName) const {
5809 bool skip = false;
5810
5811 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005812 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005813 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005814 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005815 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5816 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005817 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005818 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005819 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005820
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005821#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005822 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005823 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005824#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005825 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005826#endif
5827
sfricke-samsung1a72f942020-07-25 12:09:18 -07005828 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005829
5830 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005831 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005832 const VkComponentMapping components = pCreateInfo->components;
5833 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5834 if (FormatIsXChromaSubsampled(format) == true) {
5835 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5836 skip |=
5837 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005838 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5839 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005840 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005841 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005842
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005843 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5844 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5845 skip |= LogError(
5846 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5847 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5848 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5849 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5850 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005851
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005852 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5853 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5854 skip |=
5855 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005856 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5857 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005858 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005859 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005860
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005861 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5862 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5863 skip |=
5864 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005865 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5866 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005867 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005868 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005869
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005870 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005871 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5872 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5873 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005874 skip |=
5875 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005876 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5877 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005878 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5879 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005880 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005881 }
5882
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005883 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5884 // Checks same VU multiple ways in order to give a more useful error message
5885 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5886 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5887 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5888 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5889 skip |= LogError(
5890 device, vuid,
5891 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5892 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5893 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5894 string_VkComponentSwizzle(components.b));
5895 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005896
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005897 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5898 // 4 channel format = no issue
5899 // 3 = no [a]
5900 // 2 = no [b,a]
5901 // 1 = no [g,b,a]
5902 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5903 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5904
5905 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5906 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5907 skip |= LogError(device, vuid,
5908 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5909 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5910 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5911 string_VkComponentSwizzle(components.b));
5912 } else if ((channels < 3) &&
5913 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5914 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5915 skip |= LogError(device, vuid,
5916 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5917 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5918 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5919 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5920 string_VkComponentSwizzle(components.b));
5921 } else if ((channels < 2) &&
5922 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5923 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5924 skip |= LogError(device, vuid,
5925 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5926 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5927 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5928 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5929 string_VkComponentSwizzle(components.b));
5930 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005931 }
5932 }
5933
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005934 return skip;
5935}
5936
5937bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5938 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5939 const VkAllocationCallbacks *pAllocator,
5940 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5941 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5942 "vkCreateSamplerYcbcrConversion");
5943}
5944
5945bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5946 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5947 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5948 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5949 "vkCreateSamplerYcbcrConversionKHR");
5950}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005951
5952bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5953 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5954 bool skip = false;
5955 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5956 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5957
5958 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005959 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5960 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5961 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5962 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5963 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005964 }
5965 return skip;
5966}
sourav parmara96ab1a2020-04-25 16:28:23 -07005967
5968bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005969 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005970 bool skip = false;
5971 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5972 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5973 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5974 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005975 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005976 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5977 skip |= LogError(
5978 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5979 "vkCopyAccelerationStructureToMemoryKHR: The "
5980 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5981 }
5982 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5983 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5984 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5985 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5986 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5987 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005988 return skip;
5989}
5990
5991bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5992 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5993 bool skip = false;
5994 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5995 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5996 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5997 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5998 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005999 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6000 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006001 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006002 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006003 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006004 return skip;
6005}
6006
6007bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6008 const char *api_name) const {
6009 bool skip = false;
6010 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6011 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6012 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6013 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6014 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6015 api_name);
6016 }
6017 return skip;
6018}
6019
6020bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006021 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006022 bool skip = false;
6023 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006024 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006025 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006026 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006027 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6028 "vkCopyAccelerationStructureKHR: The "
6029 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006030 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006031 return skip;
6032}
6033
6034bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6035 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6036 bool skip = false;
6037 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6038 return skip;
6039}
6040
6041bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006042 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006043 bool skip = false;
6044 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006045 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006046 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6047 }
6048 return skip;
6049}
6050
6051bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006052 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006053 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006054 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006055 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006056 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6057 skip |= LogError(
6058 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6059 "vkCopyMemoryToAccelerationStructureKHR: The "
6060 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006061 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006062 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6063 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006064 return skip;
6065}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006066
sourav parmara96ab1a2020-04-25 16:28:23 -07006067bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6068 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6069 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006070 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006071 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6072 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006073 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006074 pInfo->src.deviceAddress);
6075 }
sourav parmar83c31b12020-05-06 12:30:54 -07006076 return skip;
6077}
6078bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6079 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6080 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6081 bool skip = false;
6082 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6083 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6084 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6085 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6086 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6087 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6088 }
6089 return skip;
6090}
6091bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6092 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6093 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6094 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006095 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006096 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6097 skip |= LogError(
6098 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6099 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6100 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6101 }
sourav parmar83c31b12020-05-06 12:30:54 -07006102 if (dataSize < accelerationStructureCount * stride) {
6103 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6104 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
6105 "accelerationStructureCount (%d) *stride(%zu).",
6106 dataSize, accelerationStructureCount, stride);
6107 }
6108 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6109 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6110 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6111 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6112 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6113 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6114 }
6115 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6116 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6117 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6118 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6119 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6120 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6121 stride);
6122 }
6123 }
6124 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6125 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6126 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6127 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6128 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6129 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6130 stride);
6131 }
6132 }
sourav parmar83c31b12020-05-06 12:30:54 -07006133 return skip;
6134}
6135bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6136 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6137 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006138 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006139 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6140 skip |= LogError(
6141 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6142 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6143 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006144 }
6145 return skip;
6146}
6147
6148bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006149 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6150 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6151 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6152 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006153 uint32_t width, uint32_t height, uint32_t depth) const {
6154 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006155 // RayGen
6156 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6157 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6158 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006159 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006160 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6161 0) {
6162 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6163 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6164 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6165 }
6166 // Callable
6167 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6168 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6169 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6170 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006171 }
6172 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6173 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6174 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006175 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6176 }
6177 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6178 0) {
6179 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6180 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6181 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006182 }
6183 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006184 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6185 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6186 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6187 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006188 }
6189 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6190 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006191 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6192 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006193 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006194 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6195 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6196 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6197 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6198 }
sourav parmar83c31b12020-05-06 12:30:54 -07006199 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006200 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6201 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6202 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6203 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006204 }
6205 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6206 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6207 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006208 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6209 }
6210 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6211 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6212 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6213 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6214 }
6215 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6216 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6217 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6218 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6219 }
6220 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6221 skip |=
6222 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6223 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6224 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006225 }
6226
sourav parmarcd5fb182020-07-17 12:58:44 -07006227 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6228 skip |=
6229 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6230 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6231 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6232 }
6233
6234 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6235 skip |=
6236 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6237 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6238 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006239 }
6240 return skip;
6241}
6242
sourav parmarcd5fb182020-07-17 12:58:44 -07006243bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6244 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6245 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6246 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006247 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006248 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006249 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6250 skip |= LogError(
6251 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6252 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6253 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006254 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006255 // RayGen
6256 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6257 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6258 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006259 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006260 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6261 0) {
6262 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6263 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6264 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6265 }
6266 // Callabe
6267 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6268 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6269 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6270 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006271 }
6272 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6273 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006274 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6275 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6276 }
6277 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6278 0) {
6279 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6280 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6281 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006282 }
6283 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006284 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6285 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6286 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6287 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006288 }
6289 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6290 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006291 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6292 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006293 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006294 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6295 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6296 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6297 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6298 }
sourav parmar83c31b12020-05-06 12:30:54 -07006299 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006300 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6301 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6302 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6303 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006304 }
6305 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6306 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006307 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6308 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6309 }
6310 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6311 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6312 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6313 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006314 }
6315
sourav parmarcd5fb182020-07-17 12:58:44 -07006316 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6317 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6318 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006319 }
6320 return skip;
6321}
6322bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6323 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6324 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6325 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6326 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6327 uint32_t width, uint32_t height, uint32_t depth) const {
6328 bool skip = false;
6329 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6330 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6331 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6332 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6333 }
6334 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6335 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6336 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6337 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6338 }
6339 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6340 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6341 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6342 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6343 }
6344
6345 // hitShader
6346 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6347 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6348 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6349 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6350 }
6351 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6352 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6353 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6354 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6355 }
6356 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6357 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6358 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6359 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6360 }
6361
6362 // missShader
6363 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6364 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6365 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6366 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6367 }
6368 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6369 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6370 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6371 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6372 }
6373 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6374 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6375 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6376 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6377 }
6378
6379 // raygenShader
6380 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6381 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6382 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006383 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6384 }
6385 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6386 skip |=
6387 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6388 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6389 }
6390 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6391 skip |=
6392 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6393 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6394 }
6395 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6396 skip |=
6397 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6398 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006399 }
6400 return skip;
6401}
6402
sourav parmar83c31b12020-05-06 12:30:54 -07006403bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006404 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6405 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006406 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006407 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6408 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006409 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6410 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006411 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006412 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6413 }
6414 return skip;
6415}
6416
Piers Daniell39842ee2020-07-10 16:42:33 -06006417bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6418 const VkViewport *pViewports) const {
6419 bool skip = false;
6420
6421 if (!physical_device_features.multiViewport) {
6422 if (viewportCount != 1) {
6423 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6424 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6425 ") is not 1.",
6426 viewportCount);
6427 }
6428 } else { // multiViewport enabled
6429 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6430 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6431 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6432 ") must "
6433 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6434 viewportCount, device_limits.maxViewports);
6435 }
6436 }
6437
6438 if (pViewports) {
6439 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6440 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6441 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6442 skip |= manual_PreCallValidateViewport(
6443 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6444 }
6445 }
6446
6447 return skip;
6448}
6449
6450bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6451 const VkRect2D *pScissors) const {
6452 bool skip = false;
6453
6454 if (!physical_device_features.multiViewport) {
6455 if (scissorCount != 1) {
6456 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6457 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6458 ") must "
6459 "be 1 when the multiViewport feature is disabled.",
6460 scissorCount);
6461 }
6462 } else { // multiViewport enabled
6463 if (scissorCount == 0) {
6464 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6465 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6466 ") must "
6467 "be great than zero.",
6468 scissorCount);
6469 } else if (scissorCount > device_limits.maxViewports) {
6470 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6471 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6472 ") must "
6473 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6474 scissorCount, device_limits.maxViewports);
6475 }
6476 }
6477
6478 if (pScissors) {
6479 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6480 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6481
6482 if (scissor.offset.x < 0) {
6483 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6484 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6485 scissor.offset.x);
6486 }
6487
6488 if (scissor.offset.y < 0) {
6489 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6490 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6491 scissor.offset.y);
6492 }
6493
6494 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6495 if (x_sum > INT32_MAX) {
6496 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6497 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6498 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6499 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6500 }
6501
6502 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6503 if (y_sum > INT32_MAX) {
6504 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6505 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6506 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6507 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6508 }
6509 }
6510 }
6511
6512 return skip;
6513}
6514
6515bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6516 uint32_t bindingCount, const VkBuffer *pBuffers,
6517 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6518 const VkDeviceSize *pStrides) const {
6519 bool skip = false;
6520 if (firstBinding >= device_limits.maxVertexInputBindings) {
6521 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6522 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6523 firstBinding, device_limits.maxVertexInputBindings);
6524 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6525 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6526 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6527 "maxVertexInputBindings (%u)",
6528 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6529 }
6530
6531 for (uint32_t i = 0; i < bindingCount; ++i) {
6532 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006533 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006534 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6535 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6536 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6537 } else {
6538 if (pOffsets[i] != 0) {
6539 skip |=
6540 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6541 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6542 }
6543 }
6544 }
6545 if (pStrides) {
6546 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6547 skip |=
6548 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006549 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i,
Piers Daniell39842ee2020-07-10 16:42:33 -06006550 pStrides[i], device_limits.maxVertexInputBindingStride);
6551 }
6552 }
6553 }
6554
6555 return skip;
6556}
sourav parmarcd5fb182020-07-17 12:58:44 -07006557
6558bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6559 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6560 bool skip = false;
6561 for (uint32_t i = 0; i < infoCount; ++i) {
6562 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6563 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6564 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6565 }
6566 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6567 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6568 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6569 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6570 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6571 api_name);
6572 }
6573 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6574 skip |=
6575 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6576 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6577 }
6578 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6579 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6580 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6581 }
6582 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6583 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6584 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6585 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6586 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6587 api_name);
6588 }
6589 if (pInfos[i].pGeometries) {
6590 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6591 skip |= validate_ranged_enum(
6592 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6593 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6594 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6595 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006596 skip |= validate_struct_type(
6597 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6598 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6599 &(pInfos[i].pGeometries[j].geometry.triangles),
6600 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6601 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6602 skip |= validate_struct_pnext(
6603 api_name,
6604 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6605 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6606 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6607 skip |=
6608 validate_ranged_enum(api_name,
6609 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6610 ParameterName::IndexVector{i, j}),
6611 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6612 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6613 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6614 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6615 &pInfos[i].pGeometries[j].geometry.triangles,
6616 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6617 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6618 skip |= validate_ranged_enum(
6619 api_name,
6620 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6621 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6622 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6623
6624 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6625 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6626 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6627 }
6628 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6629 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6630 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6631 skip |=
6632 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6633 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6634 api_name);
6635 }
6636 }
6637 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6638 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6639 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6640 &pInfos[i].pGeometries[j].geometry.instances,
6641 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6642 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6643 skip |= validate_struct_type(
6644 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6645 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6646 &(pInfos[i].pGeometries[j].geometry.instances),
6647 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6648 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6649 skip |= validate_struct_pnext(
6650 api_name,
6651 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6652 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6653 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6654
6655 skip |= validate_bool32(api_name,
6656 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6657 ParameterName::IndexVector{i, j}),
6658 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6659 }
6660 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6661 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6662 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6663 &pInfos[i].pGeometries[j].geometry.aabbs,
6664 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6665 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6666 skip |= validate_struct_type(
6667 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6668 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6669 &(pInfos[i].pGeometries[j].geometry.aabbs),
6670 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6671 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6672 skip |= validate_struct_pnext(
6673 api_name,
6674 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6675 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6676 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6677 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6678 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6679 "(%s):stride must be less than or equal to 2^32-1", api_name);
6680 }
6681 }
6682 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6683 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6684 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6685 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6686 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6687 api_name);
6688 }
6689 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6690 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6691 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6692 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6693 "of elements of"
6694 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6695 api_name);
6696 }
6697 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6698 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6699 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6700 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6701 api_name);
6702 }
6703 }
6704 }
6705 }
6706 if (pInfos[i].ppGeometries != NULL) {
6707 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6708 skip |= validate_ranged_enum(
6709 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6710 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6711 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6712 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006713 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6714 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6715 &pInfos[i].ppGeometries[j]->geometry.triangles,
6716 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6717 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6718 skip |= validate_struct_type(
6719 api_name,
6720 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
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, false, kVUIDUndefined,
6724 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6725 skip |= validate_struct_pnext(
6726 api_name,
6727 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6728 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6729 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6730 skip |= validate_ranged_enum(api_name,
6731 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6732 ParameterName::IndexVector{i, j}),
6733 "VkFormat", AllVkFormatEnums,
6734 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6735 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6736 skip |= validate_ranged_enum(api_name,
6737 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6738 ParameterName::IndexVector{i, j}),
6739 "VkIndexType", AllVkIndexTypeEnums,
6740 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6741 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6742 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6743 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6744 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6745 }
6746 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6747 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6748 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6749 skip |=
6750 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6751 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6752 api_name);
6753 }
6754 }
6755 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6756 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6757 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6758 &pInfos[i].ppGeometries[j]->geometry.instances,
6759 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6760 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6761 skip |= validate_struct_type(
6762 api_name,
6763 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
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, false, kVUIDUndefined,
6767 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6768 skip |= validate_struct_pnext(
6769 api_name,
6770 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6771 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6772 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6773 skip |= validate_bool32(api_name,
6774 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6775 ParameterName::IndexVector{i, j}),
6776 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6777 }
6778 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6779 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6780 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6781 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6782 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6783 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6784 skip |= validate_struct_type(
6785 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6786 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6787 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6788 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6789 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6790 skip |= validate_struct_pnext(
6791 api_name,
6792 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6793 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6794 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6795 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6796 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6797 "(%s):stride must be less than or equal to 2^32-1", api_name);
6798 }
6799 }
6800 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6801 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6802 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6803 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6804 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6805 api_name);
6806 }
6807 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6808 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6809 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6810 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6811 "of elements of"
6812 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6813 api_name);
6814 }
6815 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6816 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6817 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6818 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6819 api_name);
6820 }
6821 }
6822 }
6823 }
6824 }
6825 return skip;
6826}
6827bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6828 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6829 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6830 bool skip = false;
6831 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6832 for (uint32_t i = 0; i < infoCount; ++i) {
6833 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6834 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6835 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6836 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6837 "scratchData.deviceAddress member must be a multiple of "
6838 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6839 }
6840 for (uint32_t k = 0; k < infoCount; ++k) {
6841 if (i == k) continue;
6842 bool found = false;
6843 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6844 skip |= LogError(
6845 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6846 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6847 "not be "
6848 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6849 i, k);
6850 found = true;
6851 }
6852 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6853 skip |= LogError(
6854 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6855 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6856 "not be "
6857 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6858 i, k);
6859 found = true;
6860 }
6861 if (found) break;
6862 }
6863 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6864 if (pInfos[i].pGeometries) {
6865 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6866 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6867 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6868 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6869 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6870 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6871 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6872 }
6873 } else {
6874 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6875 skip |=
6876 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6877 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6878 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6879 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6880 }
6881 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006882 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006883 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6884 skip |= LogError(
6885 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6886 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6887 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6888 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006889 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6890 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006891 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6892 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6893 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6894 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6895 }
6896 }
6897 } else if (pInfos[i].ppGeometries) {
6898 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6899 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6900 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6901 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6902 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6903 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6904 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6905 }
6906 } else {
6907 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6908 skip |=
6909 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6910 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6911 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6912 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6913 }
6914 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006915 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006916 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6917 skip |= LogError(
6918 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6919 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6920 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6921 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006922 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6923 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006924 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6925 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6926 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6927 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6928 }
6929 }
6930 }
6931 }
6932 }
6933 return skip;
6934}
6935
6936bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6937 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6938 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6939 const uint32_t *const *ppMaxPrimitiveCounts) const {
6940 bool skip = false;
6941 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6942 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006943 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006944 if (!ray_tracing_acceleration_structure_features ||
6945 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6946 skip |= LogError(
6947 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6948 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6949 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6950 }
6951 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006952 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6953 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6954 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6955 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6956 "scratchData.deviceAddress member must be a multiple of "
6957 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6958 }
6959 for (uint32_t k = 0; k < infoCount; ++k) {
6960 if (i == k) continue;
6961 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6962 skip |=
6963 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6964 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6965 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6966 "any other element [%d) of pInfos.",
6967 i, k);
6968 break;
6969 }
6970 }
6971 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6972 if (pInfos[i].pGeometries) {
6973 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6974 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6975 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6976 skip |= LogError(
6977 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6978 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6979 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6980 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6981 }
6982 } else {
6983 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6984 skip |= LogError(
6985 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6986 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6987 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6988 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6989 }
6990 }
6991 }
6992 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6993 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6994 skip |= LogError(
6995 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6996 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6997 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6998 }
6999 }
7000 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7001 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7002 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7003 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7004 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7005 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7006 }
7007 }
7008 } else if (pInfos[i].ppGeometries) {
7009 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7010 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7011 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7012 skip |= LogError(
7013 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7014 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7015 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7016 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7017 }
7018 } else {
7019 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7020 skip |= LogError(
7021 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7022 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7023 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7024 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7025 }
7026 }
7027 }
7028 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7029 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7030 skip |= LogError(
7031 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7032 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7033 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7034 }
7035 }
7036 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7037 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7038 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7039 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7040 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7041 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7042 }
7043 }
7044 }
7045 }
7046 }
7047 return skip;
7048}
7049
7050bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7051 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7052 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7053 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7054 bool skip = false;
7055 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7056 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007057 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007058 if (!ray_tracing_acceleration_structure_features ||
7059 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7060 skip |=
7061 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7062 "vkBuildAccelerationStructuresKHR: The "
7063 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7064 }
7065 for (uint32_t i = 0; i < infoCount; ++i) {
7066 for (uint32_t j = 0; j < infoCount; ++j) {
7067 if (i == j) continue;
7068 bool found = false;
7069 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7070 skip |= LogError(
7071 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7072 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
7073 "not be "
7074 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7075 i, j);
7076 found = true;
7077 }
7078 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7079 skip |= LogError(
7080 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7081 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
7082 "not be "
7083 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7084 i, j);
7085 found = true;
7086 }
7087 if (found) break;
7088 }
7089 }
7090 return skip;
7091}
7092
7093bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7094 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7095 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7096 bool skip = false;
7097 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7098 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007099 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7100 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007101 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7102 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7103 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7104 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7105 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7106 }
7107 return skip;
7108}
sfricke-samsungecafb192021-01-17 08:21:14 -08007109
7110bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7111 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7112 const VkAllocationCallbacks *pAllocator,
7113 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7114 bool skip = false;
7115 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7116 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7117 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7118 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7119 }
7120 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007121}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007122
7123bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7124 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7125 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7126 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7127 bool skip = false;
7128 const auto *vertex_input_dynamic_state_features =
7129 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7130 const auto *vertex_attribute_divisor_features =
7131 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7132
7133 // VUID-vkCmdSetVertexInputEXT-None-04790
7134 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7135 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7136 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7137 }
7138
7139 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7140 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7141 skip |=
7142 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7143 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7144 }
7145
7146 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7147 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7148 skip |= LogError(
7149 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7150 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7151 }
7152
7153 // VUID-vkCmdSetVertexInputEXT-binding-04793
7154 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7155 bool binding_found = false;
7156 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7157 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7158 binding_found = true;
7159 break;
7160 }
7161 }
7162 if (!binding_found) {
7163 skip |=
7164 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7165 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
7166 }
7167 }
7168
7169 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7170 if (vertexBindingDescriptionCount > 1) {
7171 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7172 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7173 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7174 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7175 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
7176 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
7177 }
7178 }
7179 }
7180 }
7181
7182 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7183 if (vertexAttributeDescriptionCount > 1) {
7184 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7185 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7186 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7187 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7188 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
7189 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
7190 }
7191 }
7192 }
7193 }
7194
7195 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7196 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7197 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
7198 skip |= LogError(
7199 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7200 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
7201 }
7202
7203 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7204 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
7205 skip |= LogError(
7206 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7207 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
7208 binding);
7209 }
7210
7211 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7212 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7213 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7214 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7215 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7216 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7217 binding);
7218 }
7219
7220 if (pVertexBindingDescriptions[binding].divisor > 1) {
7221 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7222 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7223 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7224 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7225 "vertexAttributeInstanceRateDivisor is not enabled",
7226 binding);
7227 } else {
7228 // VUID-VkVertexInputBindingDescription2EXT-divisor-04800
7229 if (pVertexBindingDescriptions[binding].divisor >
7230 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7231 skip |= LogError(
7232 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04800",
7233 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7234 binding);
7235 }
7236
7237 // VUID-VkVertexInputBindingDescription2EXT-divisor-04801
7238 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7239 skip |=
7240 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04801",
7241 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7242 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7243 binding);
7244 }
7245 }
7246 }
7247 }
7248
7249 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7250 // VUID-VkVertexInputAttributeDescription2EXT-location-04802
7251 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7252 skip |= LogError(
7253 device, "VUID-VkVertexInputAttributeDescription2EXT-location-04802",
7254 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7255 attribute);
7256 }
7257
7258 // VUID-VkVertexInputAttributeDescription2EXT-binding-04803
7259 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7260 skip |= LogError(
7261 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-04803",
7262 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7263 attribute);
7264 }
7265
7266 // VUID-VkVertexInputAttributeDescription2EXT-offset-04804
7267 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7268 skip |= LogError(
7269 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-04804",
7270 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7271 attribute);
7272 }
7273
7274 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7275 VkFormatProperties properties;
7276 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7277 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7278 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7279 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7280 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7281 attribute);
7282 }
7283 }
7284
7285 return skip;
7286}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007287
7288bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7289 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7290 const void *pValues) const {
7291 bool skip = false;
7292 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7293 // Check that offset + size don't exceed the max.
7294 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7295 if (offset >= max_push_constants_size) {
7296 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7297 "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset,
7298 max_push_constants_size);
7299 }
7300 if (size > max_push_constants_size - offset) {
7301 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
7302 "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.",
7303 offset, size, max_push_constants_size);
7304 }
7305
7306 // size needs to be non-zero and a multiple of 4.
7307 if (size & 0x3) {
7308 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.",
7309 size);
7310 }
7311
7312 // offset needs to be a multiple of 4.
7313 if ((offset & 0x3) != 0) {
7314 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007315 "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007316 }
7317 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007318}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007319
7320bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7321 uint32_t srcCacheCount,
7322 const VkPipelineCache *pSrcCaches) const {
7323 bool skip = false;
7324 if (pSrcCaches) {
7325 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7326 if (pSrcCaches[index0] == dstCache) {
7327 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7328 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7329 report_data->FormatHandle(dstCache).c_str());
7330 break;
7331 }
7332 }
7333 }
7334 return skip;
7335}