blob: 5dc82bd9f701df9c3a6b9b54312908f8c439f162 [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
Tony-LunarG3c287f62020-12-17 12:39:49 -070039static std::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
40static 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 {
97 if (instance_extensions.vk_khr_get_physical_device_properties_2) {
98 // 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;
195 std::unordered_set<std::string> dev_exts_enumerated{};
196 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
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800304 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
305
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700306 // Save app-enabled features in this device's validation object
307 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700308 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200309 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
310 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
311 if (features2) {
312 tmp_features2_state.features = features2->features;
313 } else if (pCreateInfo->pEnabledFeatures) {
314 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700315 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200316 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700317 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200318 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700319 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200320 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700321}
322
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700323bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500324 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600325 bool skip = false;
326
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200327 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
328 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
329 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600330 }
331
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700332 // If this device supports VK_KHR_portability_subset, it must be enabled
333 const std::string portability_extension_name("VK_KHR_portability_subset");
334 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
335 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
336 bool portability_requested = false;
337
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200338 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
339 skip |=
340 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
341 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
342 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
343 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700344 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
345 portability_requested = true;
346 }
347 }
348
349 if (portability_supported && !portability_requested) {
350 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
351 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
352 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600353 }
354
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200355 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700356 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
357 bool negative_viewport =
358 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200359 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700360 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
361 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
362 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200363 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600364 }
365
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600366 {
367 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
368 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
369 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700370 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
371 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
372 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600373 }
374 }
375
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600376 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
377 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700378 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600379 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800380 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700381 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800382 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700383 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600384 }
385 }
386
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700387 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500388 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700389 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500390 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
391 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
392 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
393 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700394 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700395 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
396 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
397 skip |= LogError(
398 device,
399 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
400 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
401 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700402 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700403 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600404 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
405 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
406 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
407 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600408 }
409
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700410 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700411 if (vulkan_11_features) {
412 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
413 while (current) {
414 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
415 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
416 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
417 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
418 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
419 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700420 skip |= LogError(
421 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700422 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
423 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
424 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
425 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
426 break;
427 }
428 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
429 }
430 }
431
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700432 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700433 if (vulkan_12_features) {
434 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
435 while (current) {
436 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
437 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
438 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
439 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
440 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
441 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
442 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
443 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
444 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
445 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
446 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
447 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
448 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700449 skip |= LogError(
450 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700451 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
452 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
453 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
454 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
455 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
456 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
457 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
458 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
459 break;
460 }
461 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
462 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700463 // Check features are enabled if matching extension is passed in as well
464 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
465 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
466 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
467 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
468 skip |= LogError(
469 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
470 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
471 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
472 }
473 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
474 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
475 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
476 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
477 "is not VK_TRUE.",
478 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
479 }
480 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
481 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
482 skip |= LogError(
483 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
484 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
485 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
486 }
487 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
488 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
489 skip |= LogError(
490 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
491 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
492 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
493 }
494 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
495 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
496 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
497 skip |=
498 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
499 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
500 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
501 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
502 }
503 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700504 }
505
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600506 // Validate pCreateInfo->pQueueCreateInfos
507 if (pCreateInfo->pQueueCreateInfos) {
508 std::unordered_set<uint32_t> set;
509
510 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700511 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
512 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600513 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700514 skip |=
515 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
516 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
517 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
518 "index value.",
519 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600520 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700521 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
522 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
523 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
524 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600525 } else {
526 set.insert(requested_queue_family);
527 }
528
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700529 if (queue_create_info.pQueuePriorities != nullptr) {
530 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
531 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700533 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
534 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
535 "] (=%f) is not between 0 and 1 (inclusive).",
536 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600537 }
538 }
539 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700540
541 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700542 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700543 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700544 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700545 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700546 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700547 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700548 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700549 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700550 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700551 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
552 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
553 "protectedMemory feature being set as well.");
554 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600555 }
556 }
557
sfricke-samsung30a57412020-05-15 21:14:54 -0700558 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700559 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700560 VkBool32 variable_pointers = VK_FALSE;
561 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700562 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700563 variable_pointers = vulkan_11_features->variablePointers;
564 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700565 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700566 variable_pointers = variable_pointers_features->variablePointers;
567 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700568 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700569 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700570 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
571 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
572 }
573
sfricke-samsungfd76c342020-05-29 23:13:43 -0700574 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700575 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700576 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700577 VkBool32 multiview_geometry_shader = VK_FALSE;
578 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700579 if (vulkan_11_features) {
580 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700581 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
582 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700583 } else if (multiview_features) {
584 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700585 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
586 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700587 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700588 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700589 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
590 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
591 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700592 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700593 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
594 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
595 }
596
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600597 return skip;
598}
599
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500600bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700601 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700602 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
603 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
604 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600605 }
606
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700607 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600608}
609
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700610bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500611 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100612 bool skip = false;
613
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600614 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700615 skip |=
616 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600617
618 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
619 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
620 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
621 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700622 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
623 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
624 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600625 }
626
627 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
628 // queueFamilyIndexCount uint32_t values
629 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700630 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
631 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
632 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
633 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600634 }
635 }
636
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700637 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
638 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
639 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
640 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
641 }
642
643 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
644 skip |=
645 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
646 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
647 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
648 }
649
650 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
651 skip |=
652 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
653 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
654 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
655 }
656
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600657 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
658 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
659 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
660 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700661 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
662 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
663 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600664 }
665 }
666
667 return skip;
668}
669
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700670bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500671 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600672 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600673
674 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600675 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
676 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
677 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
678 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700679 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
680 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
681 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600682 }
683
684 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
685 // queueFamilyIndexCount uint32_t values
686 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700687 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
688 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
689 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
690 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600691 }
692 }
693
Dave Houlton413a6782018-05-22 13:01:54 -0600694 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700695 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600696 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700697 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600698 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700699 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600700
Dave Houlton413a6782018-05-22 13:01:54 -0600701 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700702 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600703 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700704 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600705
Dave Houlton130c0212018-01-29 13:39:56 -0700706 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700707 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
708 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 skip |= LogError(
710 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600711 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
712 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700713 }
714
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600715 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100716 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
717 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
719 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
720 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600721 }
722
723 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100724 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
725 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
727 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
728 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
729 ") are not equal.",
730 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100731 }
732
733 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700734 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
735 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
736 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
737 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100738 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600739 }
740
741 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700742 skip |= LogError(
743 device, "VUID-VkImageCreateInfo-imageType-00957",
744 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600745 }
746 }
747
Dave Houlton130c0212018-01-29 13:39:56 -0700748 // 3D image may have only 1 layer
749 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
751 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700752 }
753
Dave Houlton130c0212018-01-29 13:39:56 -0700754 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
755 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
756 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
757 // At least one of the legal attachment bits must be set
758 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700759 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
760 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700761 }
762 // No flags other than the legal attachment bits may be set
763 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
764 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700765 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
766 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700767 }
768 }
769
Jeff Bolzef40fec2018-09-01 22:04:34 -0500770 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700771 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500772 // Max mip levels is different for corner-sampled images vs normal images.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700773 uint32_t max_mip_levels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
774 ? static_cast<uint32_t>(ceil(log2(max_dim)))
775 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
776 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600777 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700778 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
779 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
780 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600781 }
782
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600783 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700784 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
785 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
786 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600787 }
788
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700789 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700790 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
791 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
792 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100793 }
794
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700795 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
796 skip |= LogError(
797 device, "VUID-VkImageCreateInfo-flags-01924",
798 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
799 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
800 }
801
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600802 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
803 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
804 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
805 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700806 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
807 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
808 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600809 }
810
811 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
812 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
813 // Linear tiling is unsupported
814 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700815 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700816 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
817 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600818 }
819
820 // Sparse 1D image isn't valid
821 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700822 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
823 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600824 }
825
826 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700827 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700828 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
829 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
830 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600831 }
832
833 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700834 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700835 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
836 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
837 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600838 }
839
840 // Multi-sample 2D image when device doesn't support it
841 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700842 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600843 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700844 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
845 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
846 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700847 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600848 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700849 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
850 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
851 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700852 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600853 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700854 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
855 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
856 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700857 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600858 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
860 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
861 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600862 }
863 }
864 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500865
Jeff Bolz9af91c52018-09-01 21:53:57 -0500866 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
867 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
869 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
870 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500871 }
872 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700873 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
874 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
875 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500876 }
877 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700878 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
879 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
880 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500881 }
882 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500883
884 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600885 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700886 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
887 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
888 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500889 }
890
Dave Houlton142c4cb2018-10-17 15:04:41 -0600891 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700892 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
893 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
894 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
895 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500896 }
897
Dave Houlton142c4cb2018-10-17 15:04:41 -0600898 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700899 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
900 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
901 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
902 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500903 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600904 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700905 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
906 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
907 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
908 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500909 }
910 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500911
sfricke-samsung8f658d42020-05-03 20:12:24 -0700912 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
913 (FormatHasDepth(pCreateInfo->format) == false)) {
914 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
915 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
916 "format must be a depth or depth/stencil format.");
917 }
918
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700919 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500920 if (image_stencil_struct != nullptr) {
921 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
922 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
923 // No flags other than the legal attachment bits may be set
924 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
925 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700926 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
927 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
928 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
929 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500930 }
931 }
932
933 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
934 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
935 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
936 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700937 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
938 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
939 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
940 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500941 }
942
943 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
944 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700945 LogError(device, "VUID-VkImageCreateInfo-format-02537",
946 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
947 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
948 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500949 }
950 }
951
952 if (!physical_device_features.shaderStorageImageMultisample &&
953 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
954 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
955 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700956 LogError(device, "VUID-VkImageCreateInfo-format-02538",
957 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
958 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
959 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500960 }
961
962 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
963 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700964 skip |= LogError(
965 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500966 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
967 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
968 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
969 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
970 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700971 skip |= LogError(
972 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500973 "vkCreateImage(): Depth-stencil image in which usage does not include "
974 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
975 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
976 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
977 }
978
979 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
980 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700981 skip |= LogError(
982 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500983 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
984 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
985 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
986 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
987 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700988 skip |= LogError(
989 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500990 "vkCreateImage(): Depth-stencil image in which usage does not include "
991 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
992 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
993 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
994 }
995 }
996 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700997
998 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
999 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1000 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1001 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1002 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1003 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001004
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001005 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001006 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001007 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1008 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001009 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1010 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1011 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1012 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1013 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1014 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1015 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001016 } else if (drm_format_mod_list != nullptr) {
1017 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1018 } else if (drm_format_mod_list != nullptr) {
1019 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1020 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1021 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001022 }
1023 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1024 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1025 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1026 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1027 "in the pNext chain");
1028 }
1029 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001030
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001031 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001032 bool image_create_maybe_linear = false;
1033 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1034 image_create_maybe_linear = true;
1035 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1036 image_create_maybe_linear = false;
1037 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1038 image_create_maybe_linear =
1039 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001040 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001041 }
1042
1043 // If multi-sample, validate type, usage, tiling and mip levels.
1044 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
1045 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
1046 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1047 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1048 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1049 }
1050
1051 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
1052 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1053 image_create_maybe_linear)) {
1054 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1055 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1056 }
1057
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001058 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1059 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1060 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1061 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1062 "imageType must be VK_IMAGE_TYPE_2D.");
1063 }
1064 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1065 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1066 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1067 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1068 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001069 }
1070 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
1071 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1072 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1073 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1074 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1075 }
1076 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1077 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1078 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1079 "imageType must be VK_IMAGE_TYPE_2D.");
1080 }
1081 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
1082 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1083 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1084 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1085 }
1086 if (pCreateInfo->mipLevels != 1) {
1087 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1088 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1089 pCreateInfo->mipLevels);
1090 }
1091 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001092
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001093 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001094 if (swapchain_create_info != nullptr) {
1095 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1096 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1097 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1098 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1099 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1100 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1101
1102 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1103 // also implicitly forces the check above that extent.depth is 1
1104 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1105 string_VkImageType(pCreateInfo->imageType));
1106 }
1107 if (pCreateInfo->mipLevels != 1) {
1108 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1109 pCreateInfo->mipLevels);
1110 }
1111 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1112 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1113 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1114 }
1115 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1116 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1117 base_message, string_VkImageTiling(pCreateInfo->tiling));
1118 }
1119 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1120 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1121 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1122 }
1123 const VkImageCreateFlags valid_flags =
1124 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001125 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001126 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1127 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1128 pCreateInfo->flags);
1129 }
1130 }
1131 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001132 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001133
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001134 return skip;
1135}
1136
Jeff Bolz99e3f632020-03-24 22:59:22 -05001137bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1138 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1139 bool skip = false;
1140
1141 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001142 // Validate feature set if using CUBE_ARRAY
1143 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1144 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1145 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1146 "enabling the imageCubeArray feature.");
1147 }
1148
Jeff Bolz99e3f632020-03-24 22:59:22 -05001149 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1150 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1151 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001152 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001153 pCreateInfo->subresourceRange.layerCount);
1154 }
1155 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001156 skip |= LogError(
1157 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1158 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1159 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001160 }
1161 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001162
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001163 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001164 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1165 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1166 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1167 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1168 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1169 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1170 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1171 }
1172 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1173 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1174 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1175 "not an ASTC format.",
1176 string_VkFormat(pCreateInfo->format));
1177 }
1178 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001179
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001180 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001181 if (ycbcr_conversion != nullptr) {
1182 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1183 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1184 skip |= LogError(
1185 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1186 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1187 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1188 "r swizzle = %s\n"
1189 "g swizzle = %s\n"
1190 "b swizzle = %s\n"
1191 "a swizzle = %s\n",
1192 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1193 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1194 }
1195 }
1196 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001197 }
1198 return skip;
1199}
1200
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001201bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001202 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001203 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001204
1205 // Note: for numerical correctness
1206 // - float comparisons should expect NaN (comparison always false).
1207 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1208
1209 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001210 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001211 if (v1_f <= 0.0f) return true;
1212
1213 float intpart;
1214 const float fract = modff(v1_f, &intpart);
1215
1216 assert(std::numeric_limits<float>::radix == 2);
1217 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1218 if (intpart >= u32_max_plus1) return false;
1219
1220 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001221 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001222 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001223 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001224 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001225 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001226 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001227 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001228 };
1229
1230 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1231 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1232 return (v1_f <= v2_f);
1233 };
1234
1235 // width
1236 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001237 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001238
1239 if (!(viewport.width > 0.0f)) {
1240 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001241 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1242 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001243 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1244 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001245 skip |= LogError(object, "VUID-VkViewport-width-01771",
1246 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1247 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001248 }
1249
1250 // height
1251 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001252 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001253 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001254
1255 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1256 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001257 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1258 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001259 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1260 height_healthy = false;
1261
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001262 skip |= LogError(object, "VUID-VkViewport-height-01773",
1263 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1264 ").",
1265 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001266 }
1267
1268 // x
1269 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001270 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001271 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001272 skip |= LogError(object, "VUID-VkViewport-x-01774",
1273 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1274 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001275 }
1276
1277 // x + width
1278 if (x_healthy && width_healthy) {
1279 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001280 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001281 skip |= LogError(
1282 object, "VUID-VkViewport-x-01232",
1283 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1284 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1285 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001286 }
1287 }
1288
1289 // y
1290 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001291 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001292 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001293 skip |= LogError(object, "VUID-VkViewport-y-01775",
1294 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1295 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001296 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001297 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001298 skip |= LogError(object, "VUID-VkViewport-y-01776",
1299 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1300 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001301 }
1302
1303 // y + height
1304 if (y_healthy && height_healthy) {
1305 const float boundary = viewport.y + viewport.height;
1306
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001307 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001308 skip |= LogError(object, "VUID-VkViewport-y-01233",
1309 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1310 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1311 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001312 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001313 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001314 LogError(object, "VUID-VkViewport-y-01777",
1315 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1316 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1317 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001318 }
1319 }
1320
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001321 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001322 // minDepth
1323 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001324 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001325
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001326 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1327 "[0.0, 1.0] range.",
1328 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001329 }
1330
1331 // maxDepth
1332 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001333 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001334
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001335 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1336 "[0.0, 1.0] range.",
1337 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001338 }
1339 }
1340
1341 return skip;
1342}
1343
Dave Houlton142c4cb2018-10-17 15:04:41 -06001344struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001345 VkShadingRatePaletteEntryNV shadingRate;
1346 uint32_t width;
1347 uint32_t height;
1348};
1349
1350// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001351static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001352 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1353 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1354 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1355 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1356 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1357 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001358};
1359
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001360bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001361 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001362
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001363 SampleOrderInfo *sample_order_info;
1364 uint32_t info_idx = 0;
1365 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1366 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1367 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001368 break;
1369 }
1370 }
1371
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001372 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001373 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1374 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1375 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001376 return skip;
1377 }
1378
Dave Houlton142c4cb2018-10-17 15:04:41 -06001379 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001380 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001381 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1382 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1383 ") must "
1384 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1385 "is set in framebufferNoAttachmentsSampleCounts.",
1386 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001387 }
1388
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001389 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001390 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1391 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1392 ") must "
1393 "be equal to the product of sampleCount (=%" PRIu32
1394 "), the fragment width for shadingRate "
1395 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001396 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001397 }
1398
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001399 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001400 skip |= LogError(
1401 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001402 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1403 ") must "
1404 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001405 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001406 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001407
1408 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001409 // the first width*height*sampleCount bits to all be set. Note: There is no
1410 // guarantee that 64 bits is enough, but practically it's unlikely for an
1411 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001412 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001413 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001414 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001415 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1416 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001417 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1418 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001419 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001420 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001421 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1422 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001423 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001424 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001425 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1426 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001427 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001428 uint32_t idx =
1429 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1430 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001431 }
1432
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001433 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1434 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001435 skip |= LogError(
1436 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001437 "The array pSampleLocations must contain exactly one entry for "
1438 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001439 }
1440
1441 return skip;
1442}
1443
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001444bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1445 uint32_t createInfoCount,
1446 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1447 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001448 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001449 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001450
1451 if (pCreateInfos != nullptr) {
1452 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001453 bool has_dynamic_viewport = false;
1454 bool has_dynamic_scissor = false;
1455 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001456 bool has_dynamic_depth_bias = false;
1457 bool has_dynamic_blend_constant = false;
1458 bool has_dynamic_depth_bounds = false;
1459 bool has_dynamic_stencil_compare = false;
1460 bool has_dynamic_stencil_write = false;
1461 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001462 bool has_dynamic_viewport_w_scaling_nv = false;
1463 bool has_dynamic_discard_rectangle_ext = false;
1464 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001465 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001466 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001467 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001468 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001469 bool has_dynamic_cull_mode = false;
1470 bool has_dynamic_front_face = false;
1471 bool has_dynamic_primitive_topology = false;
1472 bool has_dynamic_viewport_with_count = false;
1473 bool has_dynamic_scissor_with_count = false;
1474 bool has_dynamic_vertex_input_binding_stride = false;
1475 bool has_dynamic_depth_test_enable = false;
1476 bool has_dynamic_depth_write_enable = false;
1477 bool has_dynamic_depth_compare_op = false;
1478 bool has_dynamic_depth_bounds_test_enable = false;
1479 bool has_dynamic_stencil_test_enable = false;
1480 bool has_dynamic_stencil_op = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07001481 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
1482 skip |=
1483 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
1484 "vkCreateGraphicsPipelines: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
1485 }
Petr Kraus299ba622017-11-24 03:09:03 +01001486 if (pCreateInfos[i].pDynamicState != nullptr) {
1487 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1488 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1489 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001490 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1491 if (has_dynamic_viewport == true) {
1492 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1493 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1494 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1495 i);
1496 }
1497 has_dynamic_viewport = true;
1498 }
1499 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1500 if (has_dynamic_scissor == true) {
1501 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1502 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1503 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1504 i);
1505 }
1506 has_dynamic_scissor = true;
1507 }
1508 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1509 if (has_dynamic_line_width == true) {
1510 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1511 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1512 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1513 i);
1514 }
1515 has_dynamic_line_width = true;
1516 }
1517 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1518 if (has_dynamic_depth_bias == true) {
1519 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1520 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1521 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1522 i);
1523 }
1524 has_dynamic_depth_bias = true;
1525 }
1526 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1527 if (has_dynamic_blend_constant == true) {
1528 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1529 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1530 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1531 i);
1532 }
1533 has_dynamic_blend_constant = true;
1534 }
1535 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1536 if (has_dynamic_depth_bounds == true) {
1537 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1538 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1539 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1540 i);
1541 }
1542 has_dynamic_depth_bounds = true;
1543 }
1544 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1545 if (has_dynamic_stencil_compare == true) {
1546 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1547 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1548 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1549 i);
1550 }
1551 has_dynamic_stencil_compare = true;
1552 }
1553 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1554 if (has_dynamic_stencil_write == true) {
1555 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1556 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1557 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1558 i);
1559 }
1560 has_dynamic_stencil_write = true;
1561 }
1562 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1563 if (has_dynamic_stencil_reference == true) {
1564 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1565 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1566 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1567 i);
1568 }
1569 has_dynamic_stencil_reference = true;
1570 }
1571 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1572 if (has_dynamic_viewport_w_scaling_nv == true) {
1573 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1574 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1575 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1576 i);
1577 }
1578 has_dynamic_viewport_w_scaling_nv = true;
1579 }
1580 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1581 if (has_dynamic_discard_rectangle_ext == true) {
1582 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1583 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1584 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1585 i);
1586 }
1587 has_dynamic_discard_rectangle_ext = true;
1588 }
1589 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1590 if (has_dynamic_sample_locations_ext == true) {
1591 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1592 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1593 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1594 i);
1595 }
1596 has_dynamic_sample_locations_ext = true;
1597 }
1598 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1599 if (has_dynamic_exclusive_scissor_nv == true) {
1600 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1601 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1602 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1603 i);
1604 }
1605 has_dynamic_exclusive_scissor_nv = true;
1606 }
1607 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1608 if (has_dynamic_shading_rate_palette_nv == true) {
1609 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1610 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1611 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1612 i);
1613 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001614 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001615 }
1616 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1617 if (has_dynamic_viewport_course_sample_order_nv == true) {
1618 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1619 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1620 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1621 i);
1622 }
1623 has_dynamic_viewport_course_sample_order_nv = true;
1624 }
1625 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1626 if (has_dynamic_line_stipple == true) {
1627 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1628 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1629 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1630 i);
1631 }
1632 has_dynamic_line_stipple = true;
1633 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001634 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1635 if (has_dynamic_cull_mode) {
1636 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1637 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1638 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1639 i);
1640 }
1641 has_dynamic_cull_mode = true;
1642 }
1643 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1644 if (has_dynamic_front_face) {
1645 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1646 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1647 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1648 i);
1649 }
1650 has_dynamic_front_face = true;
1651 }
1652 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1653 if (has_dynamic_primitive_topology) {
1654 skip |= LogError(
1655 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1656 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1657 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1658 i);
1659 }
1660 has_dynamic_primitive_topology = true;
1661 }
1662 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1663 if (has_dynamic_viewport_with_count) {
1664 skip |= LogError(
1665 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1666 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1667 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1668 i);
1669 }
1670 has_dynamic_viewport_with_count = true;
1671 }
1672 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1673 if (has_dynamic_scissor_with_count) {
1674 skip |= LogError(
1675 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1676 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1677 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1678 i);
1679 }
1680 has_dynamic_scissor_with_count = true;
1681 }
1682 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1683 if (has_dynamic_vertex_input_binding_stride) {
1684 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1685 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1686 "listed twice in the "
1687 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1688 i);
1689 }
1690 has_dynamic_vertex_input_binding_stride = true;
1691 }
1692 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1693 if (has_dynamic_depth_test_enable) {
1694 skip |= LogError(
1695 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1696 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1697 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1698 i);
1699 }
1700 has_dynamic_depth_test_enable = true;
1701 }
1702 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1703 if (has_dynamic_depth_write_enable) {
1704 skip |= LogError(
1705 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1706 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1707 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1708 i);
1709 }
1710 has_dynamic_depth_write_enable = true;
1711 }
1712 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1713 if (has_dynamic_depth_compare_op) {
1714 skip |=
1715 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1716 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1717 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1718 i);
1719 }
1720 has_dynamic_depth_compare_op = true;
1721 }
1722 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1723 if (has_dynamic_depth_bounds_test_enable) {
1724 skip |= LogError(
1725 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1726 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1727 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1728 i);
1729 }
1730 has_dynamic_depth_bounds_test_enable = true;
1731 }
1732 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1733 if (has_dynamic_stencil_test_enable) {
1734 skip |= LogError(
1735 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1736 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1737 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1738 i);
1739 }
1740 has_dynamic_stencil_test_enable = true;
1741 }
1742 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1743 if (has_dynamic_stencil_op) {
1744 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1745 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1746 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1747 i);
1748 }
1749 has_dynamic_stencil_op = true;
1750 }
Petr Kraus299ba622017-11-24 03:09:03 +01001751 }
1752 }
1753
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001754 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001755 if ((feedback_struct != nullptr) &&
1756 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001757 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1758 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1759 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1760 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1761 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001762 }
1763
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001764 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001765
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001766 // Collect active stages and other information
1767 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001768 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001769 bool has_eval = false;
1770 bool has_control = false;
1771 if (pCreateInfos[i].pStages != nullptr) {
1772 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1773 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1774
1775 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1776 has_control = true;
1777 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1778 has_eval = true;
1779 }
1780
1781 skip |= validate_string(
1782 "vkCreateGraphicsPipelines",
1783 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1784 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1785 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001786 }
1787
1788 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1789 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1790 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1791 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1792 pCreateInfos[i].pTessellationState,
1793 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1794 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1795
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001796 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001797 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1798
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001799 skip |= validate_struct_pnext(
1800 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1801 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
1802 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
1803 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
1804 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1805 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001806
1807 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1808 pCreateInfos[i].pTessellationState->flags,
1809 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1810 }
1811
1812 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1813 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1814 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1815 pCreateInfos[i].pInputAssemblyState,
1816 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1817 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1818
1819 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1820 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001821 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001822
1823 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1824 pCreateInfos[i].pInputAssemblyState->flags,
1825 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1826
1827 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1828 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1829 pCreateInfos[i].pInputAssemblyState->topology,
1830 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1831
1832 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1833 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1834 }
1835
1836 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001837 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001838
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001839 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001840 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1841 "vkCreateGraphicsPipelines: pararameter "
1842 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1843 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001844 }
1845
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001846 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001847 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1848 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1849 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1850 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001851 allowed_structs_vk_pipeline_vertex_input_state_create_info,
1852 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08001853 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001854 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1855 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001856 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001857 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1858 skip |=
1859 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1860 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1861 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1862 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1863 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1864
1865 skip |= validate_array(
1866 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1867 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1868 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1869 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1870
1871 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001872 for (uint32_t vertex_binding_description_index = 0;
1873 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1874 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001875 skip |= validate_ranged_enum(
1876 "vkCreateGraphicsPipelines",
1877 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1878 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001879 pCreateInfos[i]
1880 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
1881 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001882 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1883 }
1884 }
1885
1886 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001887 for (uint32_t vertex_attribute_description_index = 0;
1888 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1889 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001890 skip |= validate_ranged_enum(
1891 "vkCreateGraphicsPipelines",
1892 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1893 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001894 pCreateInfos[i]
1895 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
1896 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001897 "VUID-VkVertexInputAttributeDescription-format-parameter");
1898 }
1899 }
1900
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001901 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001902 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1903 "vkCreateGraphicsPipelines: pararameter "
1904 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1905 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1906 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001907 }
1908
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001909 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001910 skip |=
1911 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1912 "vkCreateGraphicsPipelines: pararameter "
1913 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1914 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1915 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001916 }
1917
1918 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001919 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1920 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001921 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1922 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001923 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1924 "vkCreateGraphicsPipelines: parameter "
1925 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1926 "(%" PRIu32 ") is not distinct.",
1927 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001928 }
1929 vertex_bindings.insert(vertex_bind_desc.binding);
1930
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001931 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001932 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1933 "vkCreateGraphicsPipelines: parameter "
1934 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1935 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1936 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001937 }
1938
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001939 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001940 skip |=
1941 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1942 "vkCreateGraphicsPipelines: parameter "
1943 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1944 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1945 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001946 }
1947 }
1948
Peter Kohautc7d9d392018-07-15 00:34:07 +02001949 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001950 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1951 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001952 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1953 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001954 skip |= LogError(
1955 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001956 "vkCreateGraphicsPipelines: parameter "
1957 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1958 i, d, vertex_attrib_desc.location);
1959 }
1960 attribute_locations.insert(vertex_attrib_desc.location);
1961
1962 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1963 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001964 skip |= LogError(
1965 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001966 "vkCreateGraphicsPipelines: parameter "
1967 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1968 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1969 i, d, vertex_attrib_desc.binding, i);
1970 }
1971
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001972 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001973 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1974 "vkCreateGraphicsPipelines: parameter "
1975 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1976 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1977 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001978 }
1979
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001980 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001981 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1982 "vkCreateGraphicsPipelines: parameter "
1983 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1984 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1985 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001986 }
1987
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001988 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001989 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1990 "vkCreateGraphicsPipelines: parameter "
1991 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1992 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1993 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001994 }
1995 }
1996 }
1997
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001998 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1999 if (has_control && has_eval) {
2000 if (pCreateInfos[i].pTessellationState == nullptr) {
2001 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2002 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2003 "shader stage and a tessellation evaluation shader stage, "
2004 "pCreateInfos[%d].pTessellationState must not be NULL.",
2005 i, i);
2006 } else {
2007 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2008 skip |= validate_struct_pnext(
2009 "vkCreateGraphicsPipelines",
2010 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2011 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2012 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2013 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002014
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002015 skip |= validate_reserved_flags(
2016 "vkCreateGraphicsPipelines",
2017 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2018 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002019
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002020 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2021 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2022 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2023 "vkCreateGraphicsPipelines: invalid parameter "
2024 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2025 "should be >0 and <=%u.",
2026 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2027 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002028 }
2029 }
2030 }
2031
2032 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2033 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2034 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2035 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002036 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2037 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2038 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2039 "].pViewportState (=NULL) is not a valid pointer.",
2040 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002041 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002042 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2043
2044 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002045 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2046 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2047 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2048 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002049 }
2050
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002051 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002052 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002053 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2054 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002055 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2056 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002057 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002058 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002059 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002060 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002061 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002062 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2063 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002064 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2065 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2066 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002067 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002068
2069 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002070 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002071 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002072 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002073
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002074 auto exclusive_scissor_struct =
2075 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2076 auto shading_rate_image_struct =
2077 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2078 auto coarse_sample_order_struct =
2079 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002080 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002081 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002082 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002083 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002084
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002085 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002086 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002087 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2088 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2089 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2090 ") is not 1.",
2091 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002092 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002093
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002094 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002095 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2096 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2097 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2098 ") is not 1.",
2099 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002100 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002101
Dave Houlton142c4cb2018-10-17 15:04:41 -06002102 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2103 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002104 skip |= LogError(
2105 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2106 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2107 "disabled, but pCreateInfos[%" PRIu32
2108 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2109 ") is not 1.",
2110 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002111 }
2112
Jeff Bolz9af91c52018-09-01 21:53:57 -05002113 if (shading_rate_image_struct &&
2114 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002115 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2116 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2117 "disabled, but pCreateInfos[%" PRIu32
2118 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2119 ") is neither 0 nor 1.",
2120 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002121 }
2122
Petr Krausa6103552017-11-16 21:21:58 +01002123 } else { // multiViewport enabled
2124 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002125 if (!has_dynamic_viewport_with_count) {
2126 skip |= LogError(
2127 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2128 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2129 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002130 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002131 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2132 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2133 "].pViewportState->viewportCount (=%" PRIu32
2134 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2135 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002136 } else if (has_dynamic_viewport_with_count) {
2137 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2138 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2139 "].pViewportState->viewportCount (=%" PRIu32
2140 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2141 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002142 }
Petr Krausa6103552017-11-16 21:21:58 +01002143
2144 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002145 if (!has_dynamic_scissor_with_count) {
2146 skip |= LogError(
2147 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2148 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2149 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002150 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002151 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2152 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2153 "].pViewportState->scissorCount (=%" PRIu32
2154 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2155 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002156 } else if (has_dynamic_scissor_with_count) {
2157 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2158 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2159 "].pViewportState->scissorCount (=%" PRIu32
2160 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2161 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002162 }
2163 }
2164
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002165 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002166 skip |=
2167 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2168 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2169 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2170 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002171 }
2172
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002173 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002174 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2175 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2176 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2177 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2178 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002179 }
2180
Piers Daniell39842ee2020-07-10 16:42:33 -06002181 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2182 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002183 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2184 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2185 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2186 "].pViewportState->viewportCount (=%" PRIu32 ").",
2187 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002188 }
2189
Dave Houlton142c4cb2018-10-17 15:04:41 -06002190 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002191 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002192 skip |=
2193 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2194 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2195 ") must be zero or identical to pCreateInfos[%" PRIu32
2196 "].pViewportState->viewportCount (=%" PRIu32 ").",
2197 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002198 }
2199
Dave Houlton142c4cb2018-10-17 15:04:41 -06002200 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002201 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002202 skip |= LogError(
2203 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002204 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2205 "] "
2206 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2207 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2208 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002209 }
2210
Petr Krausa6103552017-11-16 21:21:58 +01002211 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002212 skip |= LogError(
2213 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002214 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2215 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002216 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2217 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002218 }
2219
2220 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002221 skip |= LogError(
2222 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002223 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2224 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002225 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2226 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002227 }
2228
Jeff Bolz3e71f782018-08-29 23:15:45 -05002229 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002230 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2231 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2232 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002233 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002234 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2235 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2236 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2237 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002238 }
2239
Jeff Bolz9af91c52018-09-01 21:53:57 -05002240 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002241 shading_rate_image_struct->viewportCount > 0 &&
2242 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002243 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002244 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002245 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002246 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2247 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002248 i, i);
2249 }
2250
Chris Mayer328d8212018-12-11 14:16:18 +01002251 if (vp_swizzle_struct) {
2252 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002253 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2254 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2255 " does "
2256 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2257 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002258 }
2259 }
2260
Petr Krausb3fcdb42018-01-09 22:09:09 +01002261 // validate the VkViewports
2262 if (!has_dynamic_viewport && viewport_state.pViewports) {
2263 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2264 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002265 const char *fn_name = "vkCreateGraphicsPipelines";
2266 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2267 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2268 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002269 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002270 }
2271 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002272
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002273 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002274 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2275 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2276 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2277 "VK_NV_clip_space_w_scaling extension is not enabled.",
2278 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002279 }
2280
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002281 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002282 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2283 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2284 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2285 "VK_EXT_discard_rectangles extension is not enabled.",
2286 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002287 }
2288
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002289 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002290 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2291 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2292 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2293 "VK_EXT_sample_locations extension is not enabled.",
2294 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002295 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002296
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002297 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002298 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2299 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2300 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2301 "VK_NV_scissor_exclusive extension is not enabled.",
2302 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002303 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002304
2305 if (coarse_sample_order_struct &&
2306 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2307 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002308 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2309 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2310 "] "
2311 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2312 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2313 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002314 }
2315
2316 if (coarse_sample_order_struct) {
2317 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002318 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002319 }
2320 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002321
2322 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2323 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002324 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2325 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2326 "] "
2327 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2328 ") "
2329 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2330 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002331 }
2332 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002333 skip |= LogError(
2334 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002335 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2336 "] "
2337 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2338 i);
2339 }
2340 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002341 }
2342
2343 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002344 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2345 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2346 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2347 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002348 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002349 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002350 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002351 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2352 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002353 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002354 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002355 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002356 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002357 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002358 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002359 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002360 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2361 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002362
2363 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002364 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002365 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002366 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002367
2368 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002369 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002370 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2371 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2372
2373 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002374 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002375 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2376 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002377 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002378 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002379
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002380 skip |= validate_flags(
2381 "vkCreateGraphicsPipelines",
2382 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2383 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002384 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002385
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002386 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002387 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002388 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2389 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2390
2391 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002392 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002393 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2394 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2395
2396 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002397 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002398 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2399 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2400 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002401 }
John Zulauf7acac592017-11-06 11:15:53 -07002402 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002403 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002404 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2405 "vkCreateGraphicsPipelines(): parameter "
2406 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2407 i);
John Zulauf7acac592017-11-06 11:15:53 -07002408 }
2409 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2410 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2411 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002412 skip |= LogError(
2413 device,
2414
Dave Houlton413a6782018-05-22 13:01:54 -06002415 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002416 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002417 }
2418 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002419
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002420 const auto *line_state =
2421 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002422
2423 if (line_state) {
2424 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2425 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2426 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2427 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002428 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2429 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2430 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2431 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002432 }
2433 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2434 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002435 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2436 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2437 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2438 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002439 }
2440 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2441 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002442 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2443 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2444 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2445 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002446 }
2447 }
2448 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2449 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2450 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002451 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2452 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2453 "range [1,256].",
2454 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002455 }
2456 }
2457 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002458 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002459 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2460 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002461 skip |=
2462 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2463 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2464 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2465 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002466 }
2467 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2468 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002469 skip |=
2470 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2471 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2472 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2473 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002474 }
2475 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2476 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002477 skip |=
2478 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2479 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2480 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2481 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002482 }
2483 if (line_state->stippledLineEnable) {
2484 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2485 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002486 skip |=
2487 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2488 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2489 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2490 "stippledRectangularLines feature.",
2491 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002492 }
2493 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2494 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002495 skip |=
2496 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2497 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2498 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2499 "stippledBresenhamLines feature.",
2500 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002501 }
2502 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2503 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002504 skip |=
2505 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2506 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2507 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2508 "stippledSmoothLines feature.",
2509 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002510 }
2511 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2512 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002513 skip |=
2514 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2515 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2516 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2517 "stippledRectangularLines and strictLines features.",
2518 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002519 }
2520 }
2521 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002522 }
2523
Petr Krause91f7a12017-12-14 20:57:36 +01002524 bool uses_color_attachment = false;
2525 bool uses_depthstencil_attachment = false;
2526 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002527 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002528 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2529 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002530 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002531 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002532 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002533 }
2534 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002535 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002536 }
Petr Krause91f7a12017-12-14 20:57:36 +01002537 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002538 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002539 }
2540
2541 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002542 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002543 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002544 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002545 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002546 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002547
2548 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002549 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002550 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002551 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002552
2553 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002554 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002555 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2556 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2557
2558 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002559 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002560 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2561 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2562
2563 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002564 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002565 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2566 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002567 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002568
2569 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002570 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002571 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2572 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2573
2574 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002575 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002576 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2577 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2578
2579 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002580 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002581 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2582 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002583 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002584
2585 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002586 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002587 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2588 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002589 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002590
2591 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002592 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002593 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2594 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002595 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002596
2597 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002598 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002599 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2600 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002601 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002602
2603 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002604 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002605 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2606 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002607 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002608
2609 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002610 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002611 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2612 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002613 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002614
2615 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002616 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2618 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002619 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002620
2621 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002622 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002623 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2624 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002625 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002626
2627 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002628 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002629 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2630 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2631 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002632 }
2633 }
2634
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002635 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002636 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2637
Petr Krause91f7a12017-12-14 20:57:36 +01002638 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002639 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2640 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2641 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2642 pCreateInfos[i].pColorBlendState,
2643 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2644 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2645
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002646 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002647 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002648 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2649 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002650 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2651 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002652 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2653 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002654
2655 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002656 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002657 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002658 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002659
2660 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002661 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002662 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2663 pCreateInfos[i].pColorBlendState->logicOpEnable);
2664
2665 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002666 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002667 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2668 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002669 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002670 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002671
2672 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002673 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2674 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002675 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002676 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002677 ParameterName::IndexVector{i, attachment_index}),
2678 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002679
2680 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002681 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002682 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002683 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002684 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002685 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002686 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002687
2688 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002689 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002690 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002691 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002692 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002693 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002694 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002695
2696 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002697 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002698 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002699 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002700 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002701 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002702 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002703
2704 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002705 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002706 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002707 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002709 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002710 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002711
2712 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002713 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002714 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002715 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002716 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002717 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002718 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002719
2720 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002721 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002722 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002723 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002724 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002725 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002726 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002727
2728 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002729 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002730 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002731 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002732 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002733 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002734 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002735 }
2736 }
2737
2738 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002739 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002740 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2741 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2742 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002743 }
2744
2745 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2746 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2747 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002748 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002749 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002750 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2751 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002752 }
2753 }
2754 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002755
Petr Kraus9752aae2017-11-24 03:05:50 +01002756 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2757 if (pCreateInfos[i].basePipelineIndex != -1) {
2758 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002759 skip |=
2760 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002761 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002762 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002763 "and pCreateInfos->basePipelineIndex is not -1.",
2764 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002765 }
2766 }
2767
Petr Kraus9752aae2017-11-24 03:05:50 +01002768 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2769 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002770 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002771 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002772 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002773 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2774 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002775 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002776 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002777 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002778 skip |=
2779 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2780 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2781 "index into the pCreateInfos array, of size %d.",
2782 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002783 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002784 }
2785 }
2786
sfricke-samsung898cf222020-05-15 23:10:19 -07002787 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2788 skip |= LogError(
2789 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2790 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2791 i);
2792 }
2793
Petr Kraus9752aae2017-11-24 03:05:50 +01002794 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002795 if (!device_extensions.vk_nv_fill_rectangle) {
2796 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2797 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002798 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2799 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2800 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2801 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002802 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2803 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07002804 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002805 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002806 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2807 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2808 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002809 }
2810 } else {
2811 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2812 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2813 (physical_device_features.fillModeNonSolid == false)) {
2814 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002815 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2816 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002817 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2818 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2819 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002820 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002821 }
Petr Kraus299ba622017-11-24 03:09:03 +01002822
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002823 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002824 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002825 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2826 "The line width state is static (pCreateInfos[%" PRIu32
2827 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2828 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2829 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2830 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002831 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002832 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002833 }
2834 }
2835
2836 return skip;
2837}
2838
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002839bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2840 uint32_t createInfoCount,
2841 const VkComputePipelineCreateInfo *pCreateInfos,
2842 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002843 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002844 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002845 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002846 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002847 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002848 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002849 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002850 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002851 skip |=
2852 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2853 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2854 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2855 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002856 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002857
2858 // Make sure compute stage is selected
2859 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002860 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2861 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2862 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002863 }
sourav parmarcd5fb182020-07-17 12:58:44 -07002864
2865 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
2866 skip |=
2867 LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
2868 "vkCreateComputePipelines(): flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
2869 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002871 return skip;
2872}
2873
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002874bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002875 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002877
2878 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002879 const auto &features = physical_device_features;
2880 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002881
John Zulauf71968502017-10-26 13:51:15 -06002882 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2883 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002884 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2885 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2886 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2887 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002888 }
2889
2890 // Anistropy cannot be enabled in sampler unless enabled as a feature
2891 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002892 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2893 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2894 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002895 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002896 }
John Zulauf71968502017-10-26 13:51:15 -06002897
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002898 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2899 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002900 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2901 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2902 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2903 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002904 }
2905 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002906 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2907 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2908 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2909 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002910 }
2911 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002912 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2913 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2914 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2915 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002916 }
2917 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2918 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2919 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2920 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002921 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2922 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2923 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2924 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2925 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2926 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002927 }
2928 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002929 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2930 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2931 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002932 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002933 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002934 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2935 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2936 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002937 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002938 }
2939
2940 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2941 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002942 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2943 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002944 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07002945 if (sampler_reduction != nullptr) {
2946 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2947 skip |= LogError(
2948 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2949 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2950 }
2951 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002952 }
2953
2954 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2955 // valid VkBorderColor value
2956 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2957 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2958 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002959 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2960 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002961 }
2962
2963 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2964 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002965 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002966 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2967 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2968 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002969 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002970 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2971 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2972 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973 }
John Zulauf275805c2017-10-26 15:34:49 -06002974
2975 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002976 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002977 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2978 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002979 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2980 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2981 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002982 }
2983 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002984
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002985 // Check for valid Lod range
2986 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002987 skip |=
2988 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2989 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002990 }
2991
2992 // Check mipLodBias to device limit
2993 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002994 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2995 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2996 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002997 }
2998
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002999 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003000 if (sampler_conversion != nullptr) {
3001 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3002 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3003 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3004 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003005 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003006 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003007 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3008 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3009 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3010 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3011 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3012 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3013 }
3014 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003015
3016 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3017 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3018 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3019 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3020 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3021 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3022 }
3023 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3024 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3025 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3026 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3027 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3028 }
3029 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3030 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3031 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3032 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3033 pCreateInfo->minLod, pCreateInfo->maxLod);
3034 }
3035 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3036 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3037 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3038 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3039 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3040 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3041 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3042 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3043 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3044 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3045 }
3046 if (pCreateInfo->anisotropyEnable) {
3047 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3048 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3049 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3050 }
3051 if (pCreateInfo->compareEnable) {
3052 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3053 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3054 "pCreateInfo->compareEnable must be VK_FALSE");
3055 }
3056 if (pCreateInfo->unnormalizedCoordinates) {
3057 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3058 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3059 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3060 }
3061 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003062 }
3063
Tony-LunarG7337b312020-04-15 16:40:25 -06003064 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3065 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3066 if (!device_extensions.vk_ext_custom_border_color) {
3067 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3068 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3069 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3070 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003071 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003072 if (!custom_create_info) {
3073 skip |=
3074 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3075 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3076 "struct in pNext chain.\n",
3077 string_VkBorderColor(pCreateInfo->borderColor));
3078 } else {
3079 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3080 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3081 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3082 !FormatIsSampledFloat(custom_create_info->format)))) {
3083 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3084 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3085 "whose type does not match\n",
3086 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3087 ;
3088 }
3089 }
3090 }
3091
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003092 return skip;
3093}
3094
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003095bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3096 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3097 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003098 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003099 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003100
3101 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3102 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3103 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3104 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003105 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3106 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3107 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3108 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3109 ++descriptor_index) {
3110 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003111 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003112 "vkCreateDescriptorSetLayout: required parameter "
3113 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3114 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003115 }
3116 }
3117 }
3118
3119 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3120 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3121 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003122 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3123 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3124 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3125 "values.",
3126 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003127 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003128
3129 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3130 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3131 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3132 skip |=
3133 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3134 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3135 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3136 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3137 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3138 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003139 }
3140 }
3141 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003142 return skip;
3143}
3144
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003145bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3146 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003147 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003148 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3149 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3150 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003151 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3152 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003153}
3154
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003155bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3156 const VkWriteDescriptorSet *pDescriptorWrites,
3157 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003159
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 if (pDescriptorWrites != NULL) {
3161 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3162 // descriptorCount must be greater than 0
3163 if (pDescriptorWrites[i].descriptorCount == 0) {
3164 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003165 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3166 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003167 }
3168
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003169 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3170 if (validateDstSet) {
3171 // dstSet must be a valid VkDescriptorSet handle
3172 skip |= validate_required_handle(vkCallingFunction,
3173 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3174 pDescriptorWrites[i].dstSet);
3175 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003176
3177 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3178 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3179 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3180 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3181 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3182 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3183 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003184 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3185 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003186 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003187 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3188 "%s(): if pDescriptorWrites[%d].descriptorType is "
3189 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3190 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3191 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3192 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003193 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3194 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003195 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3196 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003197 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3198 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003199 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003200 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3201 ParameterName::IndexVector{i, descriptor_index}),
3202 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003203 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003204 }
3205 }
3206 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3207 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3208 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3209 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3210 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3211 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3212 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003213 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003214 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003215 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3216 "%s(): if pDescriptorWrites[%d].descriptorType is "
3217 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3218 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3219 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3220 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003221 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003222 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003223 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003224 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003225 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3226 ++descriptor_index) {
3227 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3228 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3229 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003230 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3231 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003232 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003233 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3234 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003235 }
3236 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003237 }
3238 }
3239 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3240 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003241 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003242 }
3243
3244 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3245 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003246 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003247 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3248 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003249 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003250 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003251 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3252 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3253 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003254 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003255 }
3256 }
3257 }
3258 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3259 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003260 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003261 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3262 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003263 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003264 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003265 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3266 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3267 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003268 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003269 }
3270 }
3271 }
3272 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003273 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3274 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003275 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003276 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003277 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3278 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3279 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3280 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3281 "accelerationStructureCount %d member equals descriptorCount %d.",
3282 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3283 pDescriptorWrites[i].descriptorCount);
3284 }
3285 // further checks only if we have right structtype
3286 if (pnext_struct) {
3287 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3288 skip |= LogError(
3289 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3290 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3291 ".",
3292 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003293 }
sourav parmarbcee7512020-12-28 14:34:49 -08003294 if (pnext_struct->accelerationStructureCount == 0) {
3295 skip |= LogError(device,
3296 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3297 "%s(): accelerationStructureCount must be greater than 0 .");
3298 }
3299 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003300 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003301 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3302 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3303 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3304 skip |= LogError(device,
3305 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3306 "%s(): If the nullDescriptor feature is not enabled, each member of "
3307 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003308 }
3309 }
3310 }
sourav parmarbcee7512020-12-28 14:34:49 -08003311 }
3312 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003313 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003314 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3315 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3316 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3317 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3318 "accelerationStructureCount %d member equals descriptorCount %d.",
3319 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3320 pDescriptorWrites[i].descriptorCount);
3321 }
3322 // further checks only if we have right structtype
3323 if (pnext_struct) {
3324 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3325 skip |= LogError(
3326 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3327 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3328 ".",
3329 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003330 }
sourav parmarbcee7512020-12-28 14:34:49 -08003331 if (pnext_struct->accelerationStructureCount == 0) {
3332 skip |= LogError(device,
3333 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
3334 "%s(): accelerationStructureCount must be greater than 0 .");
3335 }
3336 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003337 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003338 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3339 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3340 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3341 skip |= LogError(device,
3342 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3343 "%s(): If the nullDescriptor feature is not enabled, each member of "
3344 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003345 }
3346 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003347 }
3348 }
3349 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003350 }
3351 }
3352 return skip;
3353}
3354
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003355bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3356 const VkWriteDescriptorSet *pDescriptorWrites,
3357 uint32_t descriptorCopyCount,
3358 const VkCopyDescriptorSet *pDescriptorCopies) const {
3359 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3360}
3361
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003362bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003363 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003364 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003365 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3366}
3367
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003368bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3369 const VkAllocationCallbacks *pAllocator,
3370 VkRenderPass *pRenderPass) const {
3371 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3372}
3373
Mike Schuchardt2df08912020-12-15 16:28:09 -08003374bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003375 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003376 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003377 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3378}
3379
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003380bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3381 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003382 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003383 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003384
3385 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3386 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3387 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003388 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3389 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003390 return skip;
3391}
3392
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003393bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003394 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003395 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003396
3397 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3398 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003399 bool cb_is_secondary;
3400 {
3401 auto lock = cb_read_lock();
3402 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3403 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003404
Tony-LunarG3c287f62020-12-17 12:39:49 -07003405 if (cb_is_secondary) {
3406 // Implicit VUs
3407 // validate only sType here; pointer has to be validated in core_validation
3408 const bool k_not_required = false;
3409 const char *k_no_vuid = nullptr;
3410 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3411 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003412 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3413 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003414
Tony-LunarG3c287f62020-12-17 12:39:49 -07003415 if (info) {
3416 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003417 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003418 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003419 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3420 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3421 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3422 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003423
Tony-LunarG3c287f62020-12-17 12:39:49 -07003424 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003425
Tony-LunarG3c287f62020-12-17 12:39:49 -07003426 // Explicit VUs
3427 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003428 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003429 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3430 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3431 cmd_name);
3432 }
3433
3434 if (physical_device_features.inheritedQueries) {
3435 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003436 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3437 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3438 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003439 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003440 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003441 }
3442
3443 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003444 skip |=
3445 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3446 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3447 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3448 } else { // !pipelineStatisticsQuery
3449 skip |=
3450 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3451 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003452 }
3453
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003454 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003455 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003456 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003457 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3458 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3459 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003460 commandBuffer,
3461 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003462 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3463 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3464 }
Petr Kraus139757b2019-08-15 17:19:33 +02003465 }
3466 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003467 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003468 return skip;
3469}
3470
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003471bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003472 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003473 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003474
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003475 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003476 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003477 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3478 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3479 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003480 }
3481 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003482 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3483 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3484 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003485 }
3486 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003487 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003488 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003489 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3490 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3491 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3492 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003493 }
3494 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003495
3496 if (pViewports) {
3497 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3498 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003499 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003500 skip |= manual_PreCallValidateViewport(
3501 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003502 }
3503 }
3504
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003505 return skip;
3506}
3507
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003508bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003509 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003510 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003511
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003512 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003513 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003514 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3515 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3516 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003517 }
3518 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003519 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3520 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3521 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003522 }
3523 } else { // multiViewport enabled
3524 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003525 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003526 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3527 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3528 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3529 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003530 }
3531 }
3532
Petr Kraus6260f0a2018-02-27 21:15:55 +01003533 if (pScissors) {
3534 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3535 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003536
Petr Kraus6260f0a2018-02-27 21:15:55 +01003537 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003538 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3539 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3540 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003541 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003542
Petr Kraus6260f0a2018-02-27 21:15:55 +01003543 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003544 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3545 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3546 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003547 }
3548
3549 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3550 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003551 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3552 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3553 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3554 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003555 }
3556
3557 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3558 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003559 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3560 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3561 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3562 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003563 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003564 }
3565 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003566
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003567 return skip;
3568}
3569
Jeff Bolz5c801d12019-10-09 10:38:45 -05003570bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003571 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003572
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003573 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003574 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3575 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003576 }
3577
3578 return skip;
3579}
3580
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003581bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003582 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003583 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003584
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003585 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003586 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003587 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3588 }
3589 if (drawCount > device_limits.maxDrawIndirectCount) {
3590 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003591 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3592 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003593 }
3594 return skip;
3595}
3596
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003597bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003598 VkDeviceSize offset, uint32_t drawCount,
3599 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003600 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003601 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003602 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3603 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3604 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003605 }
3606 if (drawCount > device_limits.maxDrawIndirectCount) {
3607 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003608 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3609 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003610 }
3611 return skip;
3612}
3613
sfricke-samsungf692b972020-05-02 08:00:45 -07003614bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3615 VkDeviceSize countBufferOffset, bool khr) const {
3616 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003617 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003618 if (offset & 3) {
3619 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003620 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003621 }
3622
3623 if (countBufferOffset & 3) {
3624 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003625 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003626 countBufferOffset);
3627 }
3628 return skip;
3629}
3630
3631bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3632 VkDeviceSize offset, VkBuffer countBuffer,
3633 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3634 uint32_t stride) const {
3635 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3636}
3637
3638bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3639 VkDeviceSize offset, VkBuffer countBuffer,
3640 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3641 uint32_t stride) const {
3642 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3643}
3644
3645bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3646 VkDeviceSize countBufferOffset, bool khr) const {
3647 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003648 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003649 if (offset & 3) {
3650 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003651 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003652 }
3653
3654 if (countBufferOffset & 3) {
3655 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003656 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003657 countBufferOffset);
3658 }
3659 return skip;
3660}
3661
3662bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3663 VkDeviceSize offset, VkBuffer countBuffer,
3664 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3665 uint32_t stride) const {
3666 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3667}
3668
3669bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3670 VkDeviceSize offset, VkBuffer countBuffer,
3671 VkDeviceSize countBufferOffset,
3672 uint32_t maxDrawCount, uint32_t stride) const {
3673 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3674}
3675
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003676bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3677 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003678 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003679 bool skip = false;
3680 for (uint32_t rect = 0; rect < rectCount; rect++) {
3681 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003682 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3683 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003684 }
sfricke-samsung10867682020-04-25 02:20:39 -07003685 if (pRects[rect].rect.extent.width == 0) {
3686 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3687 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3688 }
3689 if (pRects[rect].rect.extent.height == 0) {
3690 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3691 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3692 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003693 }
3694 return skip;
3695}
3696
Andrew Fobel3abeb992020-01-20 16:33:22 -05003697bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3698 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3699 VkImageFormatProperties2 *pImageFormatProperties,
3700 const char *apiName) const {
3701 bool skip = false;
3702
3703 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003704 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003705 if (image_stencil_struct != nullptr) {
3706 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3707 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3708 // No flags other than the legal attachment bits may be set
3709 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3710 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003711 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3712 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3713 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3714 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3715 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003716 }
3717 }
3718 }
3719 }
3720
3721 return skip;
3722}
3723
3724bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3725 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3726 VkImageFormatProperties2 *pImageFormatProperties) const {
3727 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3728 "vkGetPhysicalDeviceImageFormatProperties2");
3729}
3730
3731bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3732 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3733 VkImageFormatProperties2 *pImageFormatProperties) const {
3734 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3735 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3736}
3737
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03003738bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
3739 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
3740 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
3741 bool skip = false;
3742
3743 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
3744 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
3745 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
3746 }
3747
3748 return skip;
3749}
3750
sfricke-samsung3999ef62020-02-09 17:05:59 -08003751bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3752 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3753 bool skip = false;
3754
3755 if (pRegions != nullptr) {
3756 for (uint32_t i = 0; i < regionCount; i++) {
3757 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003758 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3759 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003760 }
3761 }
3762 }
3763 return skip;
3764}
3765
Jeff Leger178b1e52020-10-05 12:22:23 -04003766bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
3767 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
3768 bool skip = false;
3769
3770 if (pCopyBufferInfo->pRegions != nullptr) {
3771 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
3772 if (pCopyBufferInfo->pRegions[i].size == 0) {
3773 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
3774 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
3775 }
3776 }
3777 }
3778 return skip;
3779}
3780
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003781bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003782 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3783 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003784 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003785
3786 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003787 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3788 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3789 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003790 }
3791
3792 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003793 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3794 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3795 "), must be greater than zero and less than or equal to 65536.",
3796 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003797 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003798 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3799 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3800 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003801 }
3802 return skip;
3803}
3804
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003805bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003806 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003807 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003808
3809 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003810 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3811 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3812 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003813 }
3814
3815 if (size != VK_WHOLE_SIZE) {
3816 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003817 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003818 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3819 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003820 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003821 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3822 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003823 }
3824 }
3825 return skip;
3826}
3827
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003828bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003829 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003830 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003831 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003832
3833 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003834 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3835 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3836 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3837 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003838 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3839 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3840 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003841 }
3842
3843 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3844 // queueFamilyIndexCount uint32_t values
3845 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003846 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3847 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3848 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3849 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003850 }
3851 }
3852
Dave Houlton413a6782018-05-22 13:01:54 -06003853 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003854 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003855 }
3856
3857 return skip;
3858}
3859
Jeff Bolz5c801d12019-10-09 10:38:45 -05003860bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003861 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003862
3863 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003864 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06003865 if (present_regions) {
3866 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003867 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003868 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3869 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07003870 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003871 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3872 "extension swapchainCount is %i. These values must be equal.",
3873 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003874 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003875 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003876 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3877 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003878 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3879 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3880 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003881 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003882 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003883 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003884 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003885 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003886 }
3887 }
3888
3889 return skip;
3890}
3891
sfricke-samsung5c1b7392020-12-13 22:17:15 -08003892bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
3893 const VkDisplayModeCreateInfoKHR *pCreateInfo,
3894 const VkAllocationCallbacks *pAllocator,
3895 VkDisplayModeKHR *pMode) const {
3896 bool skip = false;
3897
3898 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
3899 if (display_mode_parameters.visibleRegion.width == 0) {
3900 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
3901 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
3902 }
3903 if (display_mode_parameters.visibleRegion.height == 0) {
3904 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
3905 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
3906 }
3907 if (display_mode_parameters.refreshRate == 0) {
3908 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
3909 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
3910 }
3911
3912 return skip;
3913}
3914
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003915#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003916bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3917 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3918 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003919 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003920 bool skip = false;
3921
3922 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003923 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3924 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003925 }
3926
3927 return skip;
3928}
3929#endif // VK_USE_PLATFORM_WIN32_KHR
3930
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003931bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003932 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003933 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003934 bool skip = false;
3935
3936 if (pCreateInfo) {
3937 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003938 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3939 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003940 }
3941
3942 if (pCreateInfo->pPoolSizes) {
3943 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3944 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003945 skip |= LogError(
3946 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003947 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003948 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003949 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3950 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003951 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3952 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3953 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3954 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3955 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003956 }
Petr Krausc8655be2017-09-27 18:56:51 +02003957 }
3958 }
3959 }
3960
3961 return skip;
3962}
3963
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003964bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003965 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003966 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003967
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003968 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003969 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003970 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3971 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3972 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003973 }
3974
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003975 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003976 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003977 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3978 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3979 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003980 }
3981
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003982 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003983 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003984 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3985 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3986 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003987 }
3988
3989 return skip;
3990}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003991
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003992bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003993 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003994 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003995
3996 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003997 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3998 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003999 }
4000 return skip;
4001}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004002
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004003bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4004 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004005 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004006 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004007
4008 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004009 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004010 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004011 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4012 "vkCmdDispatch(): baseGroupX (%" PRIu32
4013 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4014 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004015 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004016 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4017 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4018 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4019 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004020 }
4021
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004022 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004023 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004024 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4025 "vkCmdDispatch(): baseGroupY (%" PRIu32
4026 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4027 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004028 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004029 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4030 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4031 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4032 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004033 }
4034
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004035 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004036 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004037 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4038 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4039 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4040 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004041 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004042 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4043 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4044 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4045 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004046 }
4047
4048 return skip;
4049}
4050
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004051bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4052 VkPipelineBindPoint pipelineBindPoint,
4053 VkPipelineLayout layout, uint32_t set,
4054 uint32_t descriptorWriteCount,
4055 const VkWriteDescriptorSet *pDescriptorWrites) const {
4056 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4057}
4058
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004059bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4060 uint32_t firstExclusiveScissor,
4061 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004062 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004063 bool skip = false;
4064
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004065 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004066 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004067 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004068 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4069 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4070 ") is not 0.",
4071 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004072 }
4073 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004074 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004075 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4076 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4077 ") is not 1.",
4078 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004079 }
4080 } else { // multiViewport enabled
4081 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004082 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004083 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4084 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4085 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4086 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004087 }
4088 }
4089
Jeff Bolz3e71f782018-08-29 23:15:45 -05004090 if (pExclusiveScissors) {
4091 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4092 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4093
4094 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004095 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4096 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4097 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004098 }
4099
4100 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004101 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4102 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4103 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004104 }
4105
4106 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4107 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004108 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4109 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4110 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4111 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004112 }
4113
4114 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4115 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004116 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4117 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4118 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4119 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004120 }
4121 }
4122 }
4123
4124 return skip;
4125}
4126
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004127bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4128 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004129 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004130 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004131 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4132 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4133 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4134 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4135 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4136 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004137 }
4138
4139 return skip;
4140}
4141
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004142bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4143 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004144 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004145 bool skip = false;
4146
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004147 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004148 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004149 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004150 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4151 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4152 ") is not 0.",
4153 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004154 }
4155 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004156 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004157 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4158 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4159 ") is not 1.",
4160 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004161 }
4162 }
4163
Jeff Bolz9af91c52018-09-01 21:53:57 -05004164 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004165 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004166 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4167 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4168 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4169 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004170 }
4171
4172 return skip;
4173}
4174
Jeff Bolz5c801d12019-10-09 10:38:45 -05004175bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4176 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4177 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004178 bool skip = false;
4179
Dave Houlton142c4cb2018-10-17 15:04:41 -06004180 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004181 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4182 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4183 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004184 }
4185
4186 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004187 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004188 }
4189
4190 return skip;
4191}
4192
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004193bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004194 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004195 bool skip = false;
4196
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004197 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004198 skip |= LogError(
4199 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004200 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4201 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004202 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004203 }
4204
4205 return skip;
4206}
4207
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004208bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4209 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004210 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004211 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004212 static const int condition_multiples = 0b0011;
4213 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004214 skip |= LogError(
4215 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004216 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004217 }
Lockee1c22882019-06-10 16:02:54 -06004218 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004219 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4220 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4221 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4222 stride);
Lockee1c22882019-06-10 16:02:54 -06004223 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004224 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004225 skip |= LogError(
4226 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4227 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004228 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004229 if (drawCount > device_limits.maxDrawIndirectCount) {
4230 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004231 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4232 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004233 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004234 return skip;
4235}
4236
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004237bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4238 VkDeviceSize offset, VkBuffer countBuffer,
4239 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004240 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004241 bool skip = false;
4242
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004243 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004244 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4245 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4246 "), is not a multiple of 4.",
4247 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004248 }
4249
4250 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004251 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4252 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4253 "), is not a multiple of 4.",
4254 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004255 }
4256
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004257 return skip;
4258}
4259
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004260bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004261 const VkAllocationCallbacks *pAllocator,
4262 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004263 bool skip = false;
4264
4265 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4266 if (pCreateInfo != nullptr) {
4267 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4268 // VkQueryPipelineStatisticFlagBits values
4269 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4270 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004271 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4272 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4273 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4274 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004275 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004276 if (pCreateInfo->queryCount == 0) {
4277 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4278 "vkCreateQueryPool(): queryCount must be greater than zero.");
4279 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004280 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004281 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004282}
4283
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004284bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4285 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004286 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004287 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4288 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004289}
4290
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004291void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004292 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4293 VkResult result) {
4294 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004295 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004296}
4297
Mike Schuchardt2df08912020-12-15 16:28:09 -08004298void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004299 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4300 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004301 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004302 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004303 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004304}
4305
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004306void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4307 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004308 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004309 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004310 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004311}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004312
Tony-LunarG3c287f62020-12-17 12:39:49 -07004313void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004314 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004315 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4316 auto lock = cb_write_lock();
4317 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004318 secondary_cb_map.insert({pCommandBuffers[cb_index], pAllocateInfo->commandPool});
Tony-LunarG3c287f62020-12-17 12:39:49 -07004319 }
4320 }
4321}
4322
4323void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004324 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004325 auto lock = cb_write_lock();
4326 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4327 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4328 }
4329}
4330
4331void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004332 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004333 auto lock = cb_write_lock();
4334 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4335 if (item->second == commandPool) {
4336 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004337 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004338 ++item;
4339 }
4340 }
4341}
4342
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004343bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004344 const VkAllocationCallbacks *pAllocator,
4345 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004346 bool skip = false;
4347
4348 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004349 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004350 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004351 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4352 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004353 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004354
4355 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004356 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004357 if (flags_info) {
4358 flags = flags_info->flags;
4359 }
4360
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004361 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004362 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004363 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004364 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4365 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004366 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004367 }
4368
4369#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004370 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004371#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004372 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4373 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004374#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004375 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004376#endif
4377
4378 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004379 skip |= LogError(
4380 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004381 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4382 }
4383 if (
4384#ifdef VK_USE_PLATFORM_WIN32_KHR
4385 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4386#endif
4387 (import_memory_fd && import_memory_fd->handleType) ||
4388#ifdef VK_USE_PLATFORM_ANDROID_KHR
4389 (import_memory_ahb && import_memory_ahb->buffer) ||
4390#endif
4391 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004392 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4393 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004394 }
4395 }
4396
4397 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004398 VkBool32 capture_replay = false;
4399 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004400 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004401 if (vulkan_12_features) {
4402 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4403 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4404 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004405 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004406 if (bda_features) {
4407 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4408 buffer_device_address = bda_features->bufferDeviceAddress;
4409 }
4410 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004411 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004412 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004413 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004414 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004415 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004416 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004417 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004418 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004419 }
4420 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004421 }
4422 return skip;
4423}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004424
Jason Macnak192fa0e2019-07-26 15:07:16 -07004425bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004426 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004427 bool skip = false;
4428
4429 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4430 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4431 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004432 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004433 } else {
4434 uint32_t vertex_component_size = 0;
4435 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4436 vertex_component_size = 4;
4437 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4438 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4439 vertex_component_size = 2;
4440 }
4441 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004442 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004443 }
4444 }
4445
4446 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4447 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004448 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004449 } else {
4450 uint32_t index_element_size = 0;
4451 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4452 index_element_size = 4;
4453 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4454 index_element_size = 2;
4455 }
4456 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004457 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004458 }
4459 }
4460 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4461 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004462 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004463 }
4464 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004465 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004466 }
4467 }
4468
4469 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004470 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004471 }
4472
4473 return skip;
4474}
4475
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004476bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4477 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004478 bool skip = false;
4479
4480 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004481 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004482 }
4483 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004484 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004485 }
4486
4487 return skip;
4488}
4489
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004490bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4491 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004492 bool skip = false;
4493 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004494 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004495 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004496 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004497 }
4498 return skip;
4499}
4500
4501bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004502 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004503 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004504 bool skip = false;
4505 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004506 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4507 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4508 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004509 }
4510 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004511 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4512 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4513 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004514 }
4515 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4516 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004517 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4518 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4519 "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 -07004520 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004521 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004522 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004523 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4524 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004525 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4526 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004527 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004528 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004529 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4530 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4531 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004532 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004533 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004534 uint64_t total_triangle_count = 0;
4535 for (uint32_t i = 0; i < info.geometryCount; i++) {
4536 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004537
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004538 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004539
Jason Macnak5c954952019-07-09 15:46:12 -07004540 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4541 continue;
4542 }
4543 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4544 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004545 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004546 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4547 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4548 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004549 }
4550 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004551 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4552 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4553 for (uint32_t i = 1; i < info.geometryCount; i++) {
4554 const VkGeometryNV &geometry = info.pGeometries[i];
4555 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004556 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004557 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4558 "info.pGeometries[0].geometryType.",
4559 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004560 }
4561 }
4562 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004563 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4564 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4565 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4566 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4567 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4568 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4569 }
4570 }
4571 skip |=
4572 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004573 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004574 return skip;
4575}
4576
Ricardo Garciaa4935972019-02-21 17:43:18 +01004577bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4578 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004579 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004580 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004581 if (pCreateInfo) {
4582 if ((pCreateInfo->compactedSize != 0) &&
4583 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004584 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4585 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4586 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4587 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004588 }
Jason Macnak5c954952019-07-09 15:46:12 -07004589
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004590 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004591 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004592 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004593 return skip;
4594}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004595
Jeff Bolz5c801d12019-10-09 10:38:45 -05004596bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4597 const VkAccelerationStructureInfoNV *pInfo,
4598 VkBuffer instanceData, VkDeviceSize instanceOffset,
4599 VkBool32 update, VkAccelerationStructureNV dst,
4600 VkAccelerationStructureNV src, VkBuffer scratch,
4601 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004602 bool skip = false;
4603
4604 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004605 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004606 }
4607
4608 return skip;
4609}
4610
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004611bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4612 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4613 VkAccelerationStructureKHR *pAccelerationStructure) const {
4614 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004615 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004616 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004617 if (!acceleration_structure_features ||
4618 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
4619 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
4620 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
4621 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004622 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004623 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
4624 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004625 (acceleration_structure_features &&
4626 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07004627 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07004628 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
4629 "vkCreateAccelerationStructureKHR(): If createFlags includes "
4630 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
4631 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07004632 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004633 if (pCreateInfo->deviceAddress &&
4634 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
4635 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
4636 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
4637 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
4638 }
4639 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
4640 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
4641 "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset);
4642 }
sourav parmar83c31b12020-05-06 12:30:54 -07004643 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004644 return skip;
4645}
4646
Jason Macnak5c954952019-07-09 15:46:12 -07004647bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4648 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004649 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004650 bool skip = false;
4651 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004652 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4653 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004654 }
4655 return skip;
4656}
4657
sourav parmarcd5fb182020-07-17 12:58:44 -07004658bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
4659 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
4660 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4661 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004662 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004663 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
4664 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004665 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004666 }
4667 return skip;
4668}
4669
Peter Chen85366392019-05-14 15:20:11 -04004670bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4671 uint32_t createInfoCount,
4672 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4673 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004674 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004675 bool skip = false;
4676
4677 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004678 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04004679 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004680 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004681 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4682 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4683 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4684 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004685 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004686
4687 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004688 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07004689 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4690 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4691 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4692 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4693 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4694 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4695 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4696 }
4697 }
4698
sourav parmarf4a78252020-04-10 13:04:21 -07004699 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4700 skip |=
4701 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4702 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4703 }
4704 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4705 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4706 skip |=
4707 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4708 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4709 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4710 }
4711 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4712 if (pCreateInfos[i].basePipelineIndex != -1) {
4713 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4714 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4715 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4716 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4717 "and pCreateInfos->basePipelineIndex is not -1.");
4718 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004719 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004720 skip |=
4721 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4722 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4723 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4724 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4725 "that element.");
4726 }
sourav parmarf4a78252020-04-10 13:04:21 -07004727 }
4728 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004729 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004730 skip |=
4731 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4732 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4733 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4734 "commands pCreateInfos parameter.");
4735 }
4736 } else {
4737 if (pCreateInfos[i].basePipelineIndex != -1) {
4738 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4739 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4740 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4741 }
4742 }
4743 }
4744 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4745 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4746 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4747 }
4748 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4749 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4750 "vkCreateRayTracingPipelinesNV: flags must not include "
4751 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4752 }
4753 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4754 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4755 "vkCreateRayTracingPipelinesNV: flags must not include "
4756 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4757 }
4758 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4759 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4760 "vkCreateRayTracingPipelinesNV: flags must not include "
4761 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4762 }
4763 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4764 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4765 "vkCreateRayTracingPipelinesNV: flags must not include "
4766 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4767 }
4768 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4769 skip |= LogError(
4770 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4771 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4772 }
4773 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4774 skip |= LogError(
4775 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4776 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4777 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004778 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
4779 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
4780 "vkCreateRayTracingPipelinesNV: flags must not include "
4781 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4782 }
4783 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4784 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
4785 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
4786 }
Peter Chen85366392019-05-14 15:20:11 -04004787 }
4788
4789 return skip;
4790}
4791
sourav parmarcd5fb182020-07-17 12:58:44 -07004792bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
4793 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
4794 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004795 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004796 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004797 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
4798 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
4799 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07004800 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004801 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004802 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
4803 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4804 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
4805 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4806 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4807 }
4808 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4809 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
4810 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4811 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
4812 }
4813 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004814 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004815 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4816 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07004817 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
4818 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
4819 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004820 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4821 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4822 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004823 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004824 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07004825 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4826 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4827 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4828 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07004829 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07004830 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4831 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4832 }
4833 }
sourav parmarf4a78252020-04-10 13:04:21 -07004834 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004835 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4836 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07004837 }
4838 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004839 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07004840 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07004841 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
4842 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004843 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004844 }
4845 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4846 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
4847 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07004848 }
4849 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4850 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4851 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4852 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4853 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4854 skip |= LogError(
4855 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07004856 "vkCreateRayTracingPipelinesKHR: If flags includes "
4857 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004858 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4859 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4860 "must not be VK_SHADER_UNUSED_KHR");
4861 }
4862 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4863 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4864 skip |= LogError(
4865 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07004866 "vkCreateRayTracingPipelinesKHR: If flags includes "
4867 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004868 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4869 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4870 "element must not be VK_SHADER_UNUSED_KHR");
4871 }
4872 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004873 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
4874 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
4875 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
4876 skip |= LogError(
4877 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
4878 "vkCreateRayTracingPipelinesKHR: If "
4879 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
4880 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
4881 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4882 }
4883 }
sourav parmarf4a78252020-04-10 13:04:21 -07004884 }
4885 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4886 if (pCreateInfos[i].basePipelineIndex != -1) {
4887 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4888 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07004889 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07004890 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4891 "and pCreateInfos->basePipelineIndex is not -1.");
4892 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004893 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004894 skip |=
4895 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4896 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4897 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4898 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4899 "element.");
4900 }
sourav parmarf4a78252020-04-10 13:04:21 -07004901 }
4902 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004903 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004904 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07004905 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07004906 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4907 "commands pCreateInfos parameter %d.",
4908 pCreateInfos[i].basePipelineIndex, createInfoCount);
4909 }
4910 } else {
4911 if (pCreateInfos[i].basePipelineIndex != -1) {
4912 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07004913 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07004914 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4915 }
4916 }
4917 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004918 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
4919 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
4920 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
4921 "vkCreateRayTracingPipelinesKHR: If flags includes "
4922 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
4923 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004924 }
4925 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
4926 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
4927 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
4928 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
4929 "pLibraryInfo and pLibraryInterface must be NULL.");
4930 }
4931 if (pCreateInfos[i].pLibraryInfo) {
4932 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
4933 if (pCreateInfos[i].stageCount == 0) {
4934 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
4935 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
4936 "stageCount must not be 0.");
4937 }
4938 if (pCreateInfos[i].groupCount == 0) {
4939 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
4940 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
4941 "groupCount must not be 0.");
4942 }
4943 } else {
4944 if (pCreateInfos[i].pLibraryInterface == NULL) {
4945 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
4946 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
4947 "is greater than 0, its "
4948 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004949 }
4950 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004951 }
4952 if (pCreateInfos[i].pLibraryInterface) {
4953 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
4954 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
4955 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
4956 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
4957 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
4958 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004959 }
4960 if (deferredOperation != VK_NULL_HANDLE) {
4961 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
4962 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
4963 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
4964 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07004965 }
4966 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004967 }
4968
4969 return skip;
4970}
4971
Mike Schuchardt21638df2019-03-16 10:52:02 -07004972#ifdef VK_USE_PLATFORM_WIN32_KHR
4973bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4974 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004975 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004976 bool skip = false;
4977 if (!device_extensions.vk_khr_swapchain)
4978 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4979 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4980 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4981 if (!device_extensions.vk_khr_surface)
4982 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4983 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4984 skip |=
4985 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4986 if (!device_extensions.vk_ext_full_screen_exclusive)
4987 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4988 skip |= validate_struct_type(
4989 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4990 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4991 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4992 if (pSurfaceInfo != NULL) {
4993 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4994 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4995 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4996
4997 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4998 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4999 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5000 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005001 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5002 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005003
5004 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5005 }
5006 return skip;
5007}
5008#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005009
5010bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5011 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005012 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005013 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5014 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005015 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005016 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5017 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5018 }
5019 return skip;
5020}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005021
5022bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005023 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005024 bool skip = false;
5025
5026 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005027 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5028 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005029 }
5030
5031 return skip;
5032}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005033
5034bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005035 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005036 bool skip = false;
5037
5038 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005039 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5040 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005041 }
5042
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005043 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005044 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005045 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5046 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005047 }
5048
5049 return skip;
5050}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005051
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005052bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5053 uint32_t bindingCount, const VkBuffer *pBuffers,
5054 const VkDeviceSize *pOffsets) const {
5055 bool skip = false;
5056 if (firstBinding > device_limits.maxVertexInputBindings) {
5057 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5058 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5059 device_limits.maxVertexInputBindings);
5060 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5061 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5062 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5063 "maxVertexInputBindings (%u)",
5064 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5065 }
5066
Jeff Bolz165818a2020-05-08 11:19:03 -05005067 for (uint32_t i = 0; i < bindingCount; ++i) {
5068 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005069 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005070 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5071 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5072 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5073 } else {
5074 if (pOffsets[i] != 0) {
5075 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5076 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5077 }
5078 }
5079 }
5080 }
5081
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005082 return skip;
5083}
5084
Mark Lobodzinski84988402019-09-11 15:27:30 -06005085bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005086 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005087 bool skip = false;
5088 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005089 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5090 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005091 }
5092 return skip;
5093}
5094
5095bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005096 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005097 bool skip = false;
5098 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005099 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5100 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005101 }
5102 return skip;
5103}
Petr Kraus3d720392019-11-13 02:52:39 +01005104
5105bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5106 VkSemaphore semaphore, VkFence fence,
5107 uint32_t *pImageIndex) const {
5108 bool skip = false;
5109
5110 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005111 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5112 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005113 }
5114
5115 return skip;
5116}
5117
5118bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5119 uint32_t *pImageIndex) const {
5120 bool skip = false;
5121
5122 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005123 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5124 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005125 }
5126
5127 return skip;
5128}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005129
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005130bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5131 uint32_t firstBinding, uint32_t bindingCount,
5132 const VkBuffer *pBuffers,
5133 const VkDeviceSize *pOffsets,
5134 const VkDeviceSize *pSizes) const {
5135 bool skip = false;
5136
5137 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5138 for (uint32_t i = 0; i < bindingCount; ++i) {
5139 if (pOffsets[i] & 3) {
5140 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5141 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5142 }
5143 }
5144
5145 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5146 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5147 "%s: The firstBinding(%" PRIu32
5148 ") index is greater than or equal to "
5149 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5150 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5151 }
5152
5153 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5154 skip |=
5155 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5156 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5157 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5158 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5159 }
5160
5161 for (uint32_t i = 0; i < bindingCount; ++i) {
5162 // pSizes is optional and may be nullptr.
5163 if (pSizes != nullptr) {
5164 if (pSizes[i] != VK_WHOLE_SIZE &&
5165 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5166 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5167 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5168 ") is not VK_WHOLE_SIZE and is greater than "
5169 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5170 cmd_name, i, pSizes[i]);
5171 }
5172 }
5173 }
5174
5175 return skip;
5176}
5177
5178bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5179 uint32_t firstCounterBuffer,
5180 uint32_t counterBufferCount,
5181 const VkBuffer *pCounterBuffers,
5182 const VkDeviceSize *pCounterBufferOffsets) const {
5183 bool skip = false;
5184
5185 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5186 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5187 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5188 "%s: The firstCounterBuffer(%" PRIu32
5189 ") index is greater than or equal to "
5190 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5191 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5192 }
5193
5194 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5195 skip |=
5196 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5197 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5198 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5199 cmd_name, firstCounterBuffer, counterBufferCount,
5200 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5201 }
5202
5203 return skip;
5204}
5205
5206bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5207 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5208 const VkBuffer *pCounterBuffers,
5209 const VkDeviceSize *pCounterBufferOffsets) const {
5210 bool skip = false;
5211
5212 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5213 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5214 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5215 "%s: The firstCounterBuffer(%" PRIu32
5216 ") index is greater than or equal to "
5217 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5218 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5219 }
5220
5221 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5222 skip |=
5223 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5224 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5225 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5226 cmd_name, firstCounterBuffer, counterBufferCount,
5227 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5228 }
5229
5230 return skip;
5231}
5232
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005233bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5234 uint32_t firstInstance, VkBuffer counterBuffer,
5235 VkDeviceSize counterBufferOffset,
5236 uint32_t counterOffset, uint32_t vertexStride) const {
5237 bool skip = false;
5238
5239 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005240 skip |= LogError(
5241 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005242 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5243 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5244 }
5245
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005246 if ((counterOffset % 4) != 0) {
5247 // TODO - Update when header are updated
5248 skip |= LogError(commandBuffer, "UNASSIGNED-vkCmdDrawIndirectByteCountEXT-offset",
5249 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5250 }
5251
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005252 return skip;
5253}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005254
5255bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5256 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5257 const VkAllocationCallbacks *pAllocator,
5258 VkSamplerYcbcrConversion *pYcbcrConversion,
5259 const char *apiName) const {
5260 bool skip = false;
5261
5262 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005263 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005264 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005265 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005266 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5267 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005268 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005269 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005270 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005271
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005272#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005273 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005274 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005275#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005276 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005277#endif
5278
sfricke-samsung1a72f942020-07-25 12:09:18 -07005279 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005280
5281 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005282 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005283 const VkComponentMapping components = pCreateInfo->components;
5284 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5285 if (FormatIsXChromaSubsampled(format) == true) {
5286 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5287 skip |=
5288 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005289 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5290 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005291 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005292 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005293
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005294 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5295 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5296 skip |= LogError(
5297 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5298 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5299 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5300 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5301 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005302
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005303 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5304 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5305 skip |=
5306 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005307 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5308 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005309 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005310 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005311
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005312 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5313 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5314 skip |=
5315 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005316 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5317 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005318 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005319 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005320
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005321 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005322 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5323 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5324 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005325 skip |=
5326 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005327 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5328 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005329 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5330 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005331 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005332 }
5333
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005334 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5335 // Checks same VU multiple ways in order to give a more useful error message
5336 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5337 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5338 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5339 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5340 skip |= LogError(
5341 device, vuid,
5342 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5343 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5344 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5345 string_VkComponentSwizzle(components.b));
5346 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005347
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005348 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5349 // 4 channel format = no issue
5350 // 3 = no [a]
5351 // 2 = no [b,a]
5352 // 1 = no [g,b,a]
5353 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5354 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5355
5356 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5357 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5358 skip |= LogError(device, vuid,
5359 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5360 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5361 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5362 string_VkComponentSwizzle(components.b));
5363 } else if ((channels < 3) &&
5364 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5365 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5366 skip |= LogError(device, vuid,
5367 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5368 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5369 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5370 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5371 string_VkComponentSwizzle(components.b));
5372 } else if ((channels < 2) &&
5373 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5374 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5375 skip |= LogError(device, vuid,
5376 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5377 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5378 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5379 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5380 string_VkComponentSwizzle(components.b));
5381 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005382 }
5383 }
5384
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005385 return skip;
5386}
5387
5388bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5389 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5390 const VkAllocationCallbacks *pAllocator,
5391 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5392 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5393 "vkCreateSamplerYcbcrConversion");
5394}
5395
5396bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5397 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5398 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5399 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5400 "vkCreateSamplerYcbcrConversionKHR");
5401}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005402
5403bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5404 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5405 bool skip = false;
5406 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5407 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5408
5409 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005410 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5411 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5412 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5413 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5414 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005415 }
5416 return skip;
5417}
sourav parmara96ab1a2020-04-25 16:28:23 -07005418
5419bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005420 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005421 bool skip = false;
5422 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5423 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5424 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5425 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005426 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005427 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5428 skip |= LogError(
5429 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5430 "vkCopyAccelerationStructureToMemoryKHR: The "
5431 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5432 }
5433 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5434 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5435 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5436 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5437 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5438 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005439 return skip;
5440}
5441
5442bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5443 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5444 bool skip = false;
5445 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5446 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5447 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5448 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5449 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005450 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5451 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
5452 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.",
5453 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005454 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005455 return skip;
5456}
5457
5458bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5459 const char *api_name) const {
5460 bool skip = false;
5461 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5462 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5463 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5464 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5465 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5466 api_name);
5467 }
5468 return skip;
5469}
5470
5471bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005472 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005473 bool skip = false;
5474 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005475 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005476 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005477 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005478 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5479 "vkCopyAccelerationStructureKHR: The "
5480 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005481 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005482 return skip;
5483}
5484
5485bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5486 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5487 bool skip = false;
5488 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5489 return skip;
5490}
5491
5492bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005493 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005494 bool skip = false;
5495 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005496 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005497 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5498 }
5499 return skip;
5500}
5501
5502bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005503 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005504 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005505 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005506 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005507 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5508 skip |= LogError(
5509 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5510 "vkCopyMemoryToAccelerationStructureKHR: The "
5511 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005512 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005513 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
5514 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07005515 return skip;
5516}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005517
sourav parmara96ab1a2020-04-25 16:28:23 -07005518bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5519 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5520 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005521 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07005522 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
5523 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
5524 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.",
5525 pInfo->src.deviceAddress);
5526 }
sourav parmar83c31b12020-05-06 12:30:54 -07005527 return skip;
5528}
5529bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5530 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5531 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5532 bool skip = false;
5533 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5534 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5535 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5536 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5537 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5538 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5539 }
5540 return skip;
5541}
5542bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5543 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5544 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5545 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005546 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005547 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
5548 skip |= LogError(
5549 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
5550 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
5551 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5552 }
sourav parmar83c31b12020-05-06 12:30:54 -07005553 if (dataSize < accelerationStructureCount * stride) {
5554 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5555 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5556 "accelerationStructureCount (%d) *stride(%zu).",
5557 dataSize, accelerationStructureCount, stride);
5558 }
5559 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5560 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5561 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5562 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5563 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5564 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5565 }
5566 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5567 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5568 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5569 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5570 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5571 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5572 stride);
5573 }
5574 }
5575 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5576 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5577 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5578 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5579 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5580 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5581 stride);
5582 }
5583 }
sourav parmar83c31b12020-05-06 12:30:54 -07005584 return skip;
5585}
5586bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5587 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5588 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005589 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005590 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
5591 skip |= LogError(
5592 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
5593 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
5594 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07005595 }
5596 return skip;
5597}
5598
5599bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07005600 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5601 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
5602 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5603 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07005604 uint32_t width, uint32_t height, uint32_t depth) const {
5605 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005606 // RayGen
5607 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5608 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
5609 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005610 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005611 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5612 0) {
5613 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
5614 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5615 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5616 }
5617 // Callable
5618 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5619 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
5620 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5621 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005622 }
5623 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5624 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5625 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005626 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5627 }
5628 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5629 0) {
5630 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
5631 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5632 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005633 }
5634 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005635 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5636 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
5637 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5638 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005639 }
5640 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5641 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005642 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
5643 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07005644 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005645 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5646 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
5647 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5648 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5649 }
sourav parmar83c31b12020-05-06 12:30:54 -07005650 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005651 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5652 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
5653 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
5654 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07005655 }
5656 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5657 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5658 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005659 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5660 }
5661 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5662 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
5663 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5664 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5665 }
5666 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
5667 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
5668 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
5669 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
5670 }
5671 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
5672 skip |=
5673 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
5674 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
5675 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07005676 }
5677
sourav parmarcd5fb182020-07-17 12:58:44 -07005678 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
5679 skip |=
5680 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
5681 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
5682 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
5683 }
5684
5685 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
5686 skip |=
5687 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
5688 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
5689 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07005690 }
5691 return skip;
5692}
5693
sourav parmarcd5fb182020-07-17 12:58:44 -07005694bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
5695 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5696 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5697 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005698 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005699 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005700 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
5701 skip |= LogError(
5702 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
5703 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
5704 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005705 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005706 // RayGen
5707 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5708 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
5709 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005710 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005711 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5712 0) {
5713 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
5714 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5715 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5716 }
5717 // Callabe
5718 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5719 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
5720 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5721 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005722 }
5723 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5724 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07005725 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
5726 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5727 }
5728 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5729 0) {
5730 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
5731 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5732 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005733 }
5734 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005735 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5736 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
5737 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5738 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005739 }
5740 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5741 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005742 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
5743 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07005744 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005745 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5746 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
5747 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5748 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5749 }
sourav parmar83c31b12020-05-06 12:30:54 -07005750 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005751 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5752 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
5753 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
5754 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005755 }
5756 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5757 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07005758 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
5759 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5760 }
5761 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5762 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
5763 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5764 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005765 }
5766
sourav parmarcd5fb182020-07-17 12:58:44 -07005767 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
5768 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
5769 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07005770 }
5771 return skip;
5772}
5773bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5774 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5775 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5776 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5777 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5778 uint32_t width, uint32_t height, uint32_t depth) const {
5779 bool skip = false;
5780 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5781 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5782 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5783 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5784 }
5785 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5786 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5787 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5788 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5789 }
5790 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5791 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5792 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5793 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5794 }
5795
5796 // hitShader
5797 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5798 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5799 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5800 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5801 }
5802 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5803 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5804 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5805 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5806 }
5807 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5808 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5809 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5810 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5811 }
5812
5813 // missShader
5814 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5815 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5816 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5817 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5818 }
5819 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5820 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5821 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5822 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5823 }
5824 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5825 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5826 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5827 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5828 }
5829
5830 // raygenShader
5831 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5832 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5833 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005834 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5835 }
5836 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5837 skip |=
5838 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5839 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5840 }
5841 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5842 skip |=
5843 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5844 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5845 }
5846 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5847 skip |=
5848 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5849 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005850 }
5851 return skip;
5852}
5853
sourav parmar83c31b12020-05-06 12:30:54 -07005854bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005855 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
5856 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005857 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005858 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
5859 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005860 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
5861 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005862 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07005863 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5864 }
5865 return skip;
5866}
5867
Piers Daniell39842ee2020-07-10 16:42:33 -06005868bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5869 const VkViewport *pViewports) const {
5870 bool skip = false;
5871
5872 if (!physical_device_features.multiViewport) {
5873 if (viewportCount != 1) {
5874 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5875 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5876 ") is not 1.",
5877 viewportCount);
5878 }
5879 } else { // multiViewport enabled
5880 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5881 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5882 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5883 ") must "
5884 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5885 viewportCount, device_limits.maxViewports);
5886 }
5887 }
5888
5889 if (pViewports) {
5890 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5891 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5892 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5893 skip |= manual_PreCallValidateViewport(
5894 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5895 }
5896 }
5897
5898 return skip;
5899}
5900
5901bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5902 const VkRect2D *pScissors) const {
5903 bool skip = false;
5904
5905 if (!physical_device_features.multiViewport) {
5906 if (scissorCount != 1) {
5907 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
5908 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5909 ") must "
5910 "be 1 when the multiViewport feature is disabled.",
5911 scissorCount);
5912 }
5913 } else { // multiViewport enabled
5914 if (scissorCount == 0) {
5915 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5916 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5917 ") must "
5918 "be great than zero.",
5919 scissorCount);
5920 } else if (scissorCount > device_limits.maxViewports) {
5921 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5922 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5923 ") must "
5924 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5925 scissorCount, device_limits.maxViewports);
5926 }
5927 }
5928
5929 if (pScissors) {
5930 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
5931 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
5932
5933 if (scissor.offset.x < 0) {
5934 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5935 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
5936 scissor.offset.x);
5937 }
5938
5939 if (scissor.offset.y < 0) {
5940 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5941 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
5942 scissor.offset.y);
5943 }
5944
5945 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5946 if (x_sum > INT32_MAX) {
5947 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
5948 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5949 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5950 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
5951 }
5952
5953 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5954 if (y_sum > INT32_MAX) {
5955 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
5956 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5957 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5958 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
5959 }
5960 }
5961 }
5962
5963 return skip;
5964}
5965
5966bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5967 uint32_t bindingCount, const VkBuffer *pBuffers,
5968 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
5969 const VkDeviceSize *pStrides) const {
5970 bool skip = false;
5971 if (firstBinding >= device_limits.maxVertexInputBindings) {
5972 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
5973 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
5974 firstBinding, device_limits.maxVertexInputBindings);
5975 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5976 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
5977 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5978 "maxVertexInputBindings (%u)",
5979 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5980 }
5981
5982 for (uint32_t i = 0; i < bindingCount; ++i) {
5983 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005984 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06005985 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5986 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
5987 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5988 } else {
5989 if (pOffsets[i] != 0) {
5990 skip |=
5991 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
5992 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5993 }
5994 }
5995 }
5996 if (pStrides) {
5997 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
5998 skip |=
5999 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
6000 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
6001 pStrides[i], device_limits.maxVertexInputBindingStride);
6002 }
6003 }
6004 }
6005
6006 return skip;
6007}
sourav parmarcd5fb182020-07-17 12:58:44 -07006008
6009bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6010 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6011 bool skip = false;
6012 for (uint32_t i = 0; i < infoCount; ++i) {
6013 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6014 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6015 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6016 }
6017 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6018 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6019 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6020 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6021 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6022 api_name);
6023 }
6024 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6025 skip |=
6026 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6027 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6028 }
6029 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6030 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6031 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6032 }
6033 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6034 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6035 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6036 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6037 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6038 api_name);
6039 }
6040 if (pInfos[i].pGeometries) {
6041 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6042 skip |= validate_ranged_enum(
6043 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6044 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6045 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6046 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6047 if (pInfos[i].pGeometries[j].geometry.triangles.maxVertex <= 0) {
6048 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-maxVertex-03655",
6049 "(%s): maxVertex must be greater than 0", api_name);
6050 }
6051 skip |= validate_struct_type(
6052 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6053 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6054 &(pInfos[i].pGeometries[j].geometry.triangles),
6055 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6056 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6057 skip |= validate_struct_pnext(
6058 api_name,
6059 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6060 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6061 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6062 skip |=
6063 validate_ranged_enum(api_name,
6064 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6065 ParameterName::IndexVector{i, j}),
6066 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6067 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6068 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6069 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6070 &pInfos[i].pGeometries[j].geometry.triangles,
6071 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6072 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6073 skip |= validate_ranged_enum(
6074 api_name,
6075 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6076 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6077 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6078
6079 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6080 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6081 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6082 }
6083 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6084 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6085 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6086 skip |=
6087 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6088 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6089 api_name);
6090 }
6091 }
6092 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6093 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6094 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6095 &pInfos[i].pGeometries[j].geometry.instances,
6096 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6097 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6098 skip |= validate_struct_type(
6099 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6100 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6101 &(pInfos[i].pGeometries[j].geometry.instances),
6102 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6103 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6104 skip |= validate_struct_pnext(
6105 api_name,
6106 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6107 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6108 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6109
6110 skip |= validate_bool32(api_name,
6111 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6112 ParameterName::IndexVector{i, j}),
6113 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6114 }
6115 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6116 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6117 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6118 &pInfos[i].pGeometries[j].geometry.aabbs,
6119 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6120 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6121 skip |= validate_struct_type(
6122 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6123 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6124 &(pInfos[i].pGeometries[j].geometry.aabbs),
6125 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6126 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6127 skip |= validate_struct_pnext(
6128 api_name,
6129 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6130 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6131 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6132 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6133 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6134 "(%s):stride must be less than or equal to 2^32-1", api_name);
6135 }
6136 }
6137 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6138 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6139 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6140 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6141 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6142 api_name);
6143 }
6144 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6145 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6146 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6147 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6148 "of elements of"
6149 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6150 api_name);
6151 }
6152 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6153 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6154 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6155 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6156 api_name);
6157 }
6158 }
6159 }
6160 }
6161 if (pInfos[i].ppGeometries != NULL) {
6162 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6163 skip |= validate_ranged_enum(
6164 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6165 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6166 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6167 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6168 if (pInfos[i].ppGeometries[j]->geometry.triangles.maxVertex <= 0) {
6169 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-maxVertex-03655",
6170 "(%s): maxVertex must be greater than 0", api_name);
6171 }
6172 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6173 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6174 &pInfos[i].ppGeometries[j]->geometry.triangles,
6175 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6176 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6177 skip |= validate_struct_type(
6178 api_name,
6179 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6180 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6181 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6182 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6183 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6184 skip |= validate_struct_pnext(
6185 api_name,
6186 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6187 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6188 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6189 skip |= validate_ranged_enum(api_name,
6190 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6191 ParameterName::IndexVector{i, j}),
6192 "VkFormat", AllVkFormatEnums,
6193 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6194 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6195 skip |= validate_ranged_enum(api_name,
6196 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6197 ParameterName::IndexVector{i, j}),
6198 "VkIndexType", AllVkIndexTypeEnums,
6199 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6200 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6201 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6202 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6203 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6204 }
6205 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6206 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6207 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6208 skip |=
6209 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6210 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6211 api_name);
6212 }
6213 }
6214 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6215 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6216 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6217 &pInfos[i].ppGeometries[j]->geometry.instances,
6218 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6219 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6220 skip |= validate_struct_type(
6221 api_name,
6222 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6223 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6224 &(pInfos[i].ppGeometries[j]->geometry.instances),
6225 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6226 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6227 skip |= validate_struct_pnext(
6228 api_name,
6229 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6230 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6231 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6232 skip |= validate_bool32(api_name,
6233 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6234 ParameterName::IndexVector{i, j}),
6235 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6236 }
6237 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6238 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6239 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6240 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6241 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6242 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6243 skip |= validate_struct_type(
6244 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6245 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6246 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6247 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6248 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6249 skip |= validate_struct_pnext(
6250 api_name,
6251 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6252 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6253 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6254 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6255 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6256 "(%s):stride must be less than or equal to 2^32-1", api_name);
6257 }
6258 }
6259 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6260 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6261 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6262 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6263 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6264 api_name);
6265 }
6266 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6267 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6268 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6269 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6270 "of elements of"
6271 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6272 api_name);
6273 }
6274 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6275 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6276 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6277 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6278 api_name);
6279 }
6280 }
6281 }
6282 }
6283 }
6284 return skip;
6285}
6286bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6287 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6288 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6289 bool skip = false;
6290 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6291 for (uint32_t i = 0; i < infoCount; ++i) {
6292 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6293 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6294 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6295 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6296 "scratchData.deviceAddress member must be a multiple of "
6297 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6298 }
6299 for (uint32_t k = 0; k < infoCount; ++k) {
6300 if (i == k) continue;
6301 bool found = false;
6302 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6303 skip |= LogError(
6304 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6305 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6306 "not be "
6307 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6308 i, k);
6309 found = true;
6310 }
6311 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6312 skip |= LogError(
6313 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6314 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6315 "not be "
6316 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6317 i, k);
6318 found = true;
6319 }
6320 if (found) break;
6321 }
6322 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6323 if (pInfos[i].pGeometries) {
6324 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6325 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6326 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6327 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6328 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6329 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6330 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6331 }
6332 } else {
6333 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6334 skip |=
6335 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6336 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6337 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6338 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6339 }
6340 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006341 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006342 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6343 skip |= LogError(
6344 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6345 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6346 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6347 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006348 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6349 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006350 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6351 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6352 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6353 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6354 }
6355 }
6356 } else if (pInfos[i].ppGeometries) {
6357 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6358 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6359 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6360 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6361 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6362 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6363 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6364 }
6365 } else {
6366 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6367 skip |=
6368 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6369 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6370 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6371 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6372 }
6373 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006374 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006375 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6376 skip |= LogError(
6377 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6378 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6379 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6380 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006381 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6382 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006383 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6384 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6385 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6386 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6387 }
6388 }
6389 }
6390 }
6391 }
6392 return skip;
6393}
6394
6395bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6396 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6397 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6398 const uint32_t *const *ppMaxPrimitiveCounts) const {
6399 bool skip = false;
6400 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6401 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006402 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006403 if (!ray_tracing_acceleration_structure_features ||
6404 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6405 skip |= LogError(
6406 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6407 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6408 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6409 }
6410 for (uint32_t i = 0; i < infoCount; ++i) {
6411 if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) {
6412 if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) {
6413 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666",
6414 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is "
6415 "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be "
6416 "VK_NULL_HANDLE.");
6417 }
6418 }
6419 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6420 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6421 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6422 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6423 "scratchData.deviceAddress member must be a multiple of "
6424 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6425 }
6426 for (uint32_t k = 0; k < infoCount; ++k) {
6427 if (i == k) continue;
6428 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6429 skip |=
6430 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6431 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6432 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6433 "any other element [%d) of pInfos.",
6434 i, k);
6435 break;
6436 }
6437 }
6438 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6439 if (pInfos[i].pGeometries) {
6440 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6441 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6442 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6443 skip |= LogError(
6444 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6445 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6446 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6447 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6448 }
6449 } else {
6450 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6451 skip |= LogError(
6452 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6453 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6454 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6455 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6456 }
6457 }
6458 }
6459 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6460 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6461 skip |= LogError(
6462 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6463 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6464 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6465 }
6466 }
6467 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6468 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6469 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6470 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6471 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6472 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6473 }
6474 }
6475 } else if (pInfos[i].ppGeometries) {
6476 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6477 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6478 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6479 skip |= LogError(
6480 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6481 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6482 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6483 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6484 }
6485 } else {
6486 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6487 skip |= LogError(
6488 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6489 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6490 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6491 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6492 }
6493 }
6494 }
6495 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6496 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6497 skip |= LogError(
6498 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6499 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6500 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6501 }
6502 }
6503 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6504 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6505 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6506 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6507 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6508 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6509 }
6510 }
6511 }
6512 }
6513 }
6514 return skip;
6515}
6516
6517bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6518 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6519 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6520 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6521 bool skip = false;
6522 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6523 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006524 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006525 if (!ray_tracing_acceleration_structure_features ||
6526 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6527 skip |=
6528 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
6529 "vkBuildAccelerationStructuresKHR: The "
6530 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
6531 }
6532 for (uint32_t i = 0; i < infoCount; ++i) {
6533 for (uint32_t j = 0; j < infoCount; ++j) {
6534 if (i == j) continue;
6535 bool found = false;
6536 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6537 skip |= LogError(
6538 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6539 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
6540 "not be "
6541 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6542 i, j);
6543 found = true;
6544 }
6545 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6546 skip |= LogError(
6547 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
6548 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
6549 "not be "
6550 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6551 i, j);
6552 found = true;
6553 }
6554 if (found) break;
6555 }
6556 }
6557 return skip;
6558}
6559
6560bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
6561 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
6562 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
6563 bool skip = false;
6564 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
6565 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006566 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
6567 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006568 if (!(ray_tracing_pipeline_features || ray_query_features) ||
6569 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
6570 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
6571 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
6572 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
6573 }
6574 return skip;
6575}