blob: a2b4978e9819757e0fe58d44351329c57ff64892 [file] [log] [blame]
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070028static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060029
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070036read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); }
37write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); }
38
Jeremy Gebbencbf22862021-03-03 12:01:22 -070039static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070040static ReadWriteLock secondary_cb_map_mutex;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -070041static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); }
42static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070044bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050045 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060046 bool skip = false;
47
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070048 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060049
50 if (result == VK_STRING_ERROR_NONE) {
51 return skip;
52 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070053 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070054 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060055 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070056 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
57 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060058 }
59 return skip;
60}
61
Jeff Bolz46c0ea02019-10-09 13:06:29 -050062bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060063 bool skip = false;
64 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
65 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080066 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
67 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070068 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
69 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
70 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060071 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070072 skip |= LogWarning(instance, kVUIDUndefined,
73 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
74 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
75 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060076 }
77 }
78 return skip;
79}
80
Jeff Bolz46c0ea02019-10-09 13:06:29 -050081bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060082 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060083 // Create and use a local instance extension object, as an actual instance has not been created yet
84 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
85 InstanceExtensions local_instance_extensions;
86 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
87
John Zulauf620755c2018-04-16 11:00:43 -060088 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060089 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
90 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060091 }
92
93 return skip;
94}
95
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060096bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
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;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700195 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700196 std::vector<VkExtensionProperties> ext_props{};
197 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
198 ext_props.resize(ext_count);
199 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
200 for (uint32_t j = 0; j < ext_count; j++) {
201 dev_exts_enumerated.insert(ext_props[j].extensionName);
202 }
203 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600204 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700205 }
206}
207
208void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
209 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
210 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
211 return;
212 }
213
214 if (pPhysicalDeviceCount && pPhysicalDevices) {
215 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
216 }
217}
218
219void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
220 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
221 VkResult result) {
222 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
223 return;
224 }
225
226 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
227 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
228 const auto &group = pPhysicalDeviceGroupProperties[i];
229 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
230 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600231 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700232}
233
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600234void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
235 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
236 delete (it->second);
237 it = physical_device_properties_map.erase(it);
238 }
239};
240
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700241void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700242 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700243 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700244 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700245 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
246 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700247
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248 // Parmeter validation also uses extension data
249 stateless_validation->device_extensions = this->device_extensions;
250
251 VkPhysicalDeviceProperties device_properties = {};
252 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600253 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700254 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
255
256 if (device_extensions.vk_nv_shading_rate_image) {
257 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700258 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
259 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600260 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700261 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
262 }
263
264 if (device_extensions.vk_nv_mesh_shader) {
265 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700266 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
267 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600268 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700269 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
270 }
271
Jason Macnak5c954952019-07-09 15:46:12 -0700272 if (device_extensions.vk_nv_ray_tracing) {
273 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700274 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
275 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700276 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500277 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
278 }
279
sourav parmarcd5fb182020-07-17 12:58:44 -0700280 if (device_extensions.vk_khr_ray_tracing_pipeline) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500281 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700282 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
283 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500284 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
285 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700286 }
287
sourav parmarcd5fb182020-07-17 12:58:44 -0700288 if (device_extensions.vk_khr_acceleration_structure) {
289 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700290 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
291 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700292 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
293 phys_dev_ext_props.acc_structure_props = acc_structure_props;
294 }
295
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700296 if (device_extensions.vk_ext_transform_feedback) {
297 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700298 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
299 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700300 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
301 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
302 }
303
Piers Daniellcb6d8032021-04-19 18:51:26 -0600304 if (device_extensions.vk_ext_vertex_attribute_divisor) {
305 // Get the needed vertex attribute divisor limits
306 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
307 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
308 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
309 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
310 }
311
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800312 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
313
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700314 // Save app-enabled features in this device's validation object
315 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700316 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200317 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
318 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
319 if (features2) {
320 tmp_features2_state.features = features2->features;
321 } else if (pCreateInfo->pEnabledFeatures) {
322 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700323 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200324 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700325 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200326 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700327 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200328 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700329}
330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700331bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500332 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600333 bool skip = false;
334
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200335 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
336 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
337 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600338 }
339
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700340 // If this device supports VK_KHR_portability_subset, it must be enabled
341 const std::string portability_extension_name("VK_KHR_portability_subset");
342 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
343 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
344 bool portability_requested = false;
345
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200346 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
347 skip |=
348 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
349 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
350 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
351 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700352 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
353 portability_requested = true;
354 }
355 }
356
357 if (portability_supported && !portability_requested) {
358 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
359 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
360 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600361 }
362
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200363 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700364 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
365 bool negative_viewport =
366 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200367 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700368 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
369 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
370 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200371 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600372 }
373
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600374 {
375 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
376 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
377 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700378 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
379 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
380 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600381 }
382 }
383
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600384 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
385 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700386 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600387 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800388 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700389 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800390 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700391 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600392 }
393 }
394
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700395 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500396 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700397 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500398 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
399 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
400 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
401 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700402 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700403 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
404 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
405 skip |= LogError(
406 device,
407 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
408 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
409 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700410 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700411 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600412 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
413 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
414 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
415 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600416 }
417
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700418 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700419 if (vulkan_11_features) {
420 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
421 while (current) {
422 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
423 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
424 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
425 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
426 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
427 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700428 skip |= LogError(
429 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700430 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
431 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
432 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
433 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
434 break;
435 }
436 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
437 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800438
439 // Check features are enabled if matching extension is passed in as well
440 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
441 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
442 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
443 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
444 skip |= LogError(
445 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
446 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
447 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
448 }
449 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700450 }
451
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700452 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700453 if (vulkan_12_features) {
454 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
455 while (current) {
456 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
457 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
458 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
459 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
460 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
461 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
462 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
463 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
464 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
465 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
466 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
467 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700469 skip |= LogError(
470 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700471 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
472 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
473 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
474 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
475 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
476 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
477 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
478 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
479 break;
480 }
481 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
482 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700483 // Check features are enabled if matching extension is passed in as well
484 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
485 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
486 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
487 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
488 skip |= LogError(
489 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
490 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
491 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
492 }
493 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
494 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
495 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
496 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
497 "is not VK_TRUE.",
498 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
499 }
500 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
501 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
502 skip |= LogError(
503 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
504 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
505 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
506 }
507 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
508 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
509 skip |= LogError(
510 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
511 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
512 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
513 }
514 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
515 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
516 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
517 skip |=
518 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
519 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
520 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
521 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
522 }
523 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700524 }
525
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600526 // Validate pCreateInfo->pQueueCreateInfos
527 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600528
529 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700530 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
531 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700533 skip |=
534 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
535 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
536 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
537 "index value.",
538 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600539 }
540
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700541 if (queue_create_info.pQueuePriorities != nullptr) {
542 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
543 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600544 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
546 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
547 "] (=%f) is not between 0 and 1 (inclusive).",
548 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550 }
551 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700552
553 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700554 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700555 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700556 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700557 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700558 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700559 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700560 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700561 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700562 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700563 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
564 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
565 "protectedMemory feature being set as well.");
566 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600567 }
568 }
569
sfricke-samsung30a57412020-05-15 21:14:54 -0700570 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700571 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700572 VkBool32 variable_pointers = VK_FALSE;
573 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700574 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700575 variable_pointers = vulkan_11_features->variablePointers;
576 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700577 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700578 variable_pointers = variable_pointers_features->variablePointers;
579 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700580 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700581 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700582 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
583 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
584 }
585
sfricke-samsungfd76c342020-05-29 23:13:43 -0700586 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700587 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700588 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700589 VkBool32 multiview_geometry_shader = VK_FALSE;
590 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700591 if (vulkan_11_features) {
592 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700593 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
594 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700595 } else if (multiview_features) {
596 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700597 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
598 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700599 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700600 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700601 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
602 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
603 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700604 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700605 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
606 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
607 }
608
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600609 return skip;
610}
611
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500612bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700613 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700614 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
615 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
616 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600617 }
618
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700619 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600620}
621
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700622bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500623 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100624 bool skip = false;
625
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700627 skip |=
628 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600629
630 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
631 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
632 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
633 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700634 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
635 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
636 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600637 }
638
639 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
640 // queueFamilyIndexCount uint32_t values
641 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700642 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
643 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
644 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
645 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600646 }
647 }
648
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700649 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
650 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
651 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
652 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
653 }
654
655 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
656 skip |=
657 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
658 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
659 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
660 }
661
662 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
663 skip |=
664 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
665 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
666 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
667 }
668
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600669 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
670 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
671 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
672 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700673 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
674 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
675 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600676 }
677 }
678
679 return skip;
680}
681
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700682bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500683 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600684 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600685
686 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800687 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700688 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600689 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
690 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
691 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
692 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700693 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
694 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
695 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600696 }
697
698 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
699 // queueFamilyIndexCount uint32_t values
700 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
702 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
703 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
704 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600705 }
706 }
707
Dave Houlton413a6782018-05-22 13:01:54 -0600708 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600710 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600712 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700713 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714
Dave Houlton413a6782018-05-22 13:01:54 -0600715 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700716 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600717 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600719
Dave Houlton130c0212018-01-29 13:39:56 -0700720 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700721 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
722 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700723 skip |= LogError(
724 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600725 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
726 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700727 }
728
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600729 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100730 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
731 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700732 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
733 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
734 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600735 }
736
737 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700738 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100739 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
741 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
742 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
743 ") are not equal.",
744 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100745 }
746
747 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700748 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
749 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
750 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
751 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100752 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 }
754
755 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700756 skip |= LogError(
757 device, "VUID-VkImageCreateInfo-imageType-00957",
758 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600759 }
760 }
761
Dave Houlton130c0212018-01-29 13:39:56 -0700762 // 3D image may have only 1 layer
763 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700764 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
765 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700766 }
767
Dave Houlton130c0212018-01-29 13:39:56 -0700768 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
769 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
770 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
771 // At least one of the legal attachment bits must be set
772 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
774 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700775 }
776 // No flags other than the legal attachment bits may be set
777 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
778 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700779 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
780 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700781 }
782 }
783
Jeff Bolzef40fec2018-09-01 22:04:34 -0500784 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700785 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500786 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700787 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700788 ? static_cast<uint32_t>(ceil(log2(max_dim)))
789 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
790 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600791 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700792 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
793 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
794 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600795 }
796
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700797 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700798 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
799 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
800 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600801 }
802
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700803 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700804 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
805 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
806 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100807 }
808
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700809 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700810 skip |= LogError(
811 device, "VUID-VkImageCreateInfo-flags-01924",
812 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
813 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
814 }
815
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600816 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
817 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700818 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
819 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700820 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
821 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
822 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600823 }
824
825 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700826 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600827 // Linear tiling is unsupported
828 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700829 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700830 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
831 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600832 }
833
834 // Sparse 1D image isn't valid
835 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700836 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
837 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600838 }
839
840 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700841 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700842 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
843 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
844 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600845 }
846
847 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700848 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700849 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
850 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
851 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600852 }
853
854 // Multi-sample 2D image when device doesn't support it
855 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700856 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600857 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700858 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
859 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
860 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700861 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600862 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700863 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
864 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
865 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700866 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600867 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
869 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
870 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700871 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600872 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700873 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
874 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
875 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600876 }
877 }
878 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500879
Jeff Bolz9af91c52018-09-01 21:53:57 -0500880 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
881 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700882 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
883 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
884 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500885 }
886 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700887 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
888 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
889 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500890 }
891 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700892 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
893 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
894 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500895 }
896 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500897
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700898 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600899 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700900 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
901 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
902 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500903 }
904
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700905 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700906 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
907 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800908 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
909 "depth/stencil format.",
910 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500911 }
912
Dave Houlton142c4cb2018-10-17 15:04:41 -0600913 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700914 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
915 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
916 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
917 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500918 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600919 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700920 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
921 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
922 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
923 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500924 }
925 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500926
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700927 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800928 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700929 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
930 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800931 "format (%s) must be a depth or depth/stencil format.",
932 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700933 }
934
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700935 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500936 if (image_stencil_struct != nullptr) {
937 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
938 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
939 // No flags other than the legal attachment bits may be set
940 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
941 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700942 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
943 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
944 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
945 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500946 }
947 }
948
sfricke-samsung61a57c02021-01-10 21:35:12 -0800949 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500950 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
951 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800952 skip |= LogError(
953 device, "VUID-VkImageCreateInfo-Format-02536",
954 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
955 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
956 "maxFramebufferWidth (%u)",
957 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500958 }
959
960 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800961 skip |= LogError(
962 device, "VUID-VkImageCreateInfo-format-02537",
963 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
964 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
965 "maxFramebufferHeight (%u)",
966 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500967 }
968 }
969
970 if (!physical_device_features.shaderStorageImageMultisample &&
971 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
972 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
973 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700974 LogError(device, "VUID-VkImageCreateInfo-format-02538",
975 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
976 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
977 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500978 }
979
980 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
981 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700982 skip |= LogError(
983 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500984 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
985 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
986 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
987 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
988 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700989 skip |= LogError(
990 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500991 "vkCreateImage(): Depth-stencil image in which usage does not include "
992 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
993 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
994 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
995 }
996
997 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
998 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700999 skip |= LogError(
1000 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001001 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1002 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1003 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1004 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1005 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001006 skip |= LogError(
1007 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001008 "vkCreateImage(): Depth-stencil image in which usage does not include "
1009 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1010 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1011 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1012 }
1013 }
1014 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001015
1016 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1017 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1018 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1019 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1020 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1021 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001022
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001023 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001024 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001025 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1026 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001027 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1028 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1029 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1030 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1031 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1032 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1033 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001034 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001035 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1036 } else if (drm_format_mod_list != nullptr) {
1037 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1038 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1039 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001040 }
1041 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1042 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1043 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1044 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1045 "in the pNext chain");
1046 }
1047 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001048
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001049 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001050 bool image_create_maybe_linear = false;
1051 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1052 image_create_maybe_linear = true;
1053 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1054 image_create_maybe_linear = false;
1055 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1056 image_create_maybe_linear =
1057 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001058 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001059 }
1060
1061 // If multi-sample, validate type, usage, tiling and mip levels.
1062 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001063 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001064 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1065 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1066 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1067 }
1068
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001069 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001070 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1071 image_create_maybe_linear)) {
1072 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1073 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1074 }
1075
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001076 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1077 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1078 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1079 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1080 "imageType must be VK_IMAGE_TYPE_2D.");
1081 }
1082 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1083 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1084 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1085 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1086 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001087 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001088 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001089 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1090 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1091 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1092 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1093 }
1094 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1095 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1096 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1097 "imageType must be VK_IMAGE_TYPE_2D.");
1098 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001099 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001100 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1101 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1102 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1103 }
1104 if (pCreateInfo->mipLevels != 1) {
1105 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1106 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1107 pCreateInfo->mipLevels);
1108 }
1109 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001110
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001111 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001112 if (swapchain_create_info != nullptr) {
1113 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1114 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1115 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1116 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1117 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1118 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1119
1120 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1121 // also implicitly forces the check above that extent.depth is 1
1122 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1123 string_VkImageType(pCreateInfo->imageType));
1124 }
1125 if (pCreateInfo->mipLevels != 1) {
1126 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1127 pCreateInfo->mipLevels);
1128 }
1129 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1130 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1131 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1132 }
1133 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1134 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1135 base_message, string_VkImageTiling(pCreateInfo->tiling));
1136 }
1137 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1138 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1139 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1140 }
1141 const VkImageCreateFlags valid_flags =
1142 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001143 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001144 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001145 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001146 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001147 }
1148 }
1149 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001150
1151 // If Chroma subsampled format ( _420_ or _422_ )
1152 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1153 skip |=
1154 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1155 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1156 ") must be a multiple of 2.",
1157 string_VkFormat(image_format), pCreateInfo->extent.width);
1158 }
1159 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1160 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1161 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1162 ") must be a multiple of 2.",
1163 string_VkFormat(image_format), pCreateInfo->extent.height);
1164 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001165
1166 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1167 if (format_list_info) {
1168 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1169 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1170 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1171 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1172 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1173 viewFormatCount);
1174 }
1175 // Check if viewFormatCount is not zero that it is all compatible
1176 for (uint32_t i = 0; i < viewFormatCount; i++) {
1177 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1178 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1179 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1180 "VkImageCreateInfo::format (%s) are not compatible.",
1181 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1182 }
1183 }
1184 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001185 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001186
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001187 return skip;
1188}
1189
Jeff Bolz99e3f632020-03-24 22:59:22 -05001190bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1191 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1192 bool skip = false;
1193
1194 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001195 // Validate feature set if using CUBE_ARRAY
1196 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1197 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1198 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1199 "enabling the imageCubeArray feature.");
1200 }
1201
Jeff Bolz99e3f632020-03-24 22:59:22 -05001202 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1203 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1204 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001205 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001206 pCreateInfo->subresourceRange.layerCount);
1207 }
1208 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001209 skip |= LogError(
1210 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1211 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1212 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001213 }
1214 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001215
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001216 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001217 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1218 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1219 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1220 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1221 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1222 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1223 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1224 }
1225 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1226 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1227 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1228 "not an ASTC format.",
1229 string_VkFormat(pCreateInfo->format));
1230 }
1231 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001232
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001233 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001234 if (ycbcr_conversion != nullptr) {
1235 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1236 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1237 skip |= LogError(
1238 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1239 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1240 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1241 "r swizzle = %s\n"
1242 "g swizzle = %s\n"
1243 "b swizzle = %s\n"
1244 "a swizzle = %s\n",
1245 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1246 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1247 }
1248 }
1249 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001250 }
1251 return skip;
1252}
1253
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001254bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001255 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001256 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001257
1258 // Note: for numerical correctness
1259 // - float comparisons should expect NaN (comparison always false).
1260 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1261
1262 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001263 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001264 if (v1_f <= 0.0f) return true;
1265
1266 float intpart;
1267 const float fract = modff(v1_f, &intpart);
1268
1269 assert(std::numeric_limits<float>::radix == 2);
1270 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1271 if (intpart >= u32_max_plus1) return false;
1272
1273 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001274 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001275 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001276 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001277 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001278 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001279 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001280 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001281 };
1282
1283 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1284 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1285 return (v1_f <= v2_f);
1286 };
1287
1288 // width
1289 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001290 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001291
1292 if (!(viewport.width > 0.0f)) {
1293 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001294 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1295 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001296 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1297 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001298 skip |= LogError(object, "VUID-VkViewport-width-01771",
1299 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1300 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001301 }
1302
1303 // height
1304 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001305 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001306 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001307
1308 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1309 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001310 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1311 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001312 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1313 height_healthy = false;
1314
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001315 skip |= LogError(object, "VUID-VkViewport-height-01773",
1316 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1317 ").",
1318 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001319 }
1320
1321 // x
1322 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001323 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001324 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001325 skip |= LogError(object, "VUID-VkViewport-x-01774",
1326 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1327 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001328 }
1329
1330 // x + width
1331 if (x_healthy && width_healthy) {
1332 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001333 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001334 skip |= LogError(
1335 object, "VUID-VkViewport-x-01232",
1336 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1337 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1338 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001339 }
1340 }
1341
1342 // y
1343 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001344 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001345 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001346 skip |= LogError(object, "VUID-VkViewport-y-01775",
1347 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1348 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001349 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001350 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001351 skip |= LogError(object, "VUID-VkViewport-y-01776",
1352 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1353 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001354 }
1355
1356 // y + height
1357 if (y_healthy && height_healthy) {
1358 const float boundary = viewport.y + viewport.height;
1359
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001360 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001361 skip |= LogError(object, "VUID-VkViewport-y-01233",
1362 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1363 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1364 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001365 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001366 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001367 LogError(object, "VUID-VkViewport-y-01777",
1368 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1369 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1370 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001371 }
1372 }
1373
sfricke-samsungfd06d422021-01-22 02:17:21 -08001374 // The extension was not created with a feature bit whichs prevents displaying the 2 variations of the VUIDs
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001375 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001376 // minDepth
1377 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001378 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001379 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001380 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1381 "[0.0, 1.0] range.",
1382 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001383 }
1384
1385 // maxDepth
1386 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001387 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001388 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001389 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1390 "[0.0, 1.0] range.",
1391 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001392 }
1393 }
1394
1395 return skip;
1396}
1397
Dave Houlton142c4cb2018-10-17 15:04:41 -06001398struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001399 VkShadingRatePaletteEntryNV shadingRate;
1400 uint32_t width;
1401 uint32_t height;
1402};
1403
1404// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001405static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001406 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1407 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1408 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1409 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1410 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1411 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001412};
1413
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001414bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001415 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001416
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001417 SampleOrderInfo *sample_order_info;
1418 uint32_t info_idx = 0;
1419 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1420 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1421 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001422 break;
1423 }
1424 }
1425
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001426 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001427 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1428 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1429 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001430 return skip;
1431 }
1432
Dave Houlton142c4cb2018-10-17 15:04:41 -06001433 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001434 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001435 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1436 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1437 ") must "
1438 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1439 "is set in framebufferNoAttachmentsSampleCounts.",
1440 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001441 }
1442
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001443 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001444 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1445 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1446 ") must "
1447 "be equal to the product of sampleCount (=%" PRIu32
1448 "), the fragment width for shadingRate "
1449 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001450 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001451 }
1452
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001453 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001454 skip |= LogError(
1455 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001456 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1457 ") must "
1458 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001459 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001460 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001461
1462 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001463 // the first width*height*sampleCount bits to all be set. Note: There is no
1464 // guarantee that 64 bits is enough, but practically it's unlikely for an
1465 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001466 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001467 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001468 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001469 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1470 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001471 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1472 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001473 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001474 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001475 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1476 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001477 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001478 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001479 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1480 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001481 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001482 uint32_t idx =
1483 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1484 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001485 }
1486
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001487 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1488 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001489 skip |= LogError(
1490 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001491 "The array pSampleLocations must contain exactly one entry for "
1492 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001493 }
1494
1495 return skip;
1496}
1497
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001498bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1499 uint32_t createInfoCount,
1500 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1501 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001502 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001503 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001504
1505 if (pCreateInfos != nullptr) {
1506 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001507 bool has_dynamic_viewport = false;
1508 bool has_dynamic_scissor = false;
1509 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001510 bool has_dynamic_depth_bias = false;
1511 bool has_dynamic_blend_constant = false;
1512 bool has_dynamic_depth_bounds = false;
1513 bool has_dynamic_stencil_compare = false;
1514 bool has_dynamic_stencil_write = false;
1515 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001516 bool has_dynamic_viewport_w_scaling_nv = false;
1517 bool has_dynamic_discard_rectangle_ext = false;
1518 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001519 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001520 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001521 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001522 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001523 bool has_dynamic_cull_mode = false;
1524 bool has_dynamic_front_face = false;
1525 bool has_dynamic_primitive_topology = false;
1526 bool has_dynamic_viewport_with_count = false;
1527 bool has_dynamic_scissor_with_count = false;
1528 bool has_dynamic_vertex_input_binding_stride = false;
1529 bool has_dynamic_depth_test_enable = false;
1530 bool has_dynamic_depth_write_enable = false;
1531 bool has_dynamic_depth_compare_op = false;
1532 bool has_dynamic_depth_bounds_test_enable = false;
1533 bool has_dynamic_stencil_test_enable = false;
1534 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001535 bool has_patch_control_points = false;
1536 bool has_rasterizer_discard_enable = false;
1537 bool has_depth_bias_enable = false;
1538 bool has_logic_op = false;
1539 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001540 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001541 if (pCreateInfos[i].pDynamicState != nullptr) {
1542 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1543 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1544 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001545 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1546 if (has_dynamic_viewport == true) {
1547 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1548 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1549 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1550 i);
1551 }
1552 has_dynamic_viewport = true;
1553 }
1554 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1555 if (has_dynamic_scissor == true) {
1556 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1557 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1558 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1559 i);
1560 }
1561 has_dynamic_scissor = true;
1562 }
1563 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1564 if (has_dynamic_line_width == true) {
1565 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1566 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1567 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1568 i);
1569 }
1570 has_dynamic_line_width = true;
1571 }
1572 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1573 if (has_dynamic_depth_bias == true) {
1574 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1575 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1576 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1577 i);
1578 }
1579 has_dynamic_depth_bias = true;
1580 }
1581 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1582 if (has_dynamic_blend_constant == true) {
1583 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1584 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1585 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1586 i);
1587 }
1588 has_dynamic_blend_constant = true;
1589 }
1590 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1591 if (has_dynamic_depth_bounds == true) {
1592 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1593 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1594 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1595 i);
1596 }
1597 has_dynamic_depth_bounds = true;
1598 }
1599 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1600 if (has_dynamic_stencil_compare == true) {
1601 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1602 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1603 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1604 i);
1605 }
1606 has_dynamic_stencil_compare = true;
1607 }
1608 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1609 if (has_dynamic_stencil_write == true) {
1610 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1611 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1612 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1613 i);
1614 }
1615 has_dynamic_stencil_write = true;
1616 }
1617 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1618 if (has_dynamic_stencil_reference == true) {
1619 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1620 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1621 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1622 i);
1623 }
1624 has_dynamic_stencil_reference = true;
1625 }
1626 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1627 if (has_dynamic_viewport_w_scaling_nv == true) {
1628 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1629 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1630 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1631 i);
1632 }
1633 has_dynamic_viewport_w_scaling_nv = true;
1634 }
1635 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1636 if (has_dynamic_discard_rectangle_ext == true) {
1637 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1638 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1639 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1640 i);
1641 }
1642 has_dynamic_discard_rectangle_ext = true;
1643 }
1644 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1645 if (has_dynamic_sample_locations_ext == true) {
1646 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1647 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1648 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1649 i);
1650 }
1651 has_dynamic_sample_locations_ext = true;
1652 }
1653 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1654 if (has_dynamic_exclusive_scissor_nv == true) {
1655 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1656 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1657 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1658 i);
1659 }
1660 has_dynamic_exclusive_scissor_nv = true;
1661 }
1662 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1663 if (has_dynamic_shading_rate_palette_nv == true) {
1664 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1665 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1666 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1667 i);
1668 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001669 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001670 }
1671 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1672 if (has_dynamic_viewport_course_sample_order_nv == true) {
1673 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1674 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1675 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1676 i);
1677 }
1678 has_dynamic_viewport_course_sample_order_nv = true;
1679 }
1680 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1681 if (has_dynamic_line_stipple == true) {
1682 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1683 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1684 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1685 i);
1686 }
1687 has_dynamic_line_stipple = true;
1688 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001689 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1690 if (has_dynamic_cull_mode) {
1691 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1692 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1693 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1694 i);
1695 }
1696 has_dynamic_cull_mode = true;
1697 }
1698 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1699 if (has_dynamic_front_face) {
1700 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1701 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1702 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1703 i);
1704 }
1705 has_dynamic_front_face = true;
1706 }
1707 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1708 if (has_dynamic_primitive_topology) {
1709 skip |= LogError(
1710 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1711 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1712 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1713 i);
1714 }
1715 has_dynamic_primitive_topology = true;
1716 }
1717 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1718 if (has_dynamic_viewport_with_count) {
1719 skip |= LogError(
1720 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1721 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1722 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1723 i);
1724 }
1725 has_dynamic_viewport_with_count = true;
1726 }
1727 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1728 if (has_dynamic_scissor_with_count) {
1729 skip |= LogError(
1730 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1731 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1732 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1733 i);
1734 }
1735 has_dynamic_scissor_with_count = true;
1736 }
1737 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1738 if (has_dynamic_vertex_input_binding_stride) {
1739 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1740 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1741 "listed twice in the "
1742 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1743 i);
1744 }
1745 has_dynamic_vertex_input_binding_stride = true;
1746 }
1747 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1748 if (has_dynamic_depth_test_enable) {
1749 skip |= LogError(
1750 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1751 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1752 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1753 i);
1754 }
1755 has_dynamic_depth_test_enable = true;
1756 }
1757 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1758 if (has_dynamic_depth_write_enable) {
1759 skip |= LogError(
1760 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1761 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1762 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1763 i);
1764 }
1765 has_dynamic_depth_write_enable = true;
1766 }
1767 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1768 if (has_dynamic_depth_compare_op) {
1769 skip |=
1770 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1771 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1772 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1773 i);
1774 }
1775 has_dynamic_depth_compare_op = true;
1776 }
1777 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1778 if (has_dynamic_depth_bounds_test_enable) {
1779 skip |= LogError(
1780 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1781 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1782 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1783 i);
1784 }
1785 has_dynamic_depth_bounds_test_enable = true;
1786 }
1787 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1788 if (has_dynamic_stencil_test_enable) {
1789 skip |= LogError(
1790 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1791 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1792 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1793 i);
1794 }
1795 has_dynamic_stencil_test_enable = true;
1796 }
1797 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1798 if (has_dynamic_stencil_op) {
1799 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1800 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1801 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1802 i);
1803 }
1804 has_dynamic_stencil_op = true;
1805 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001806 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1807 // Not allowed for graphics pipelines
1808 skip |= LogError(
1809 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1810 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1811 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1812 i, state_index);
1813 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001814 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1815 if (has_patch_control_points) {
1816 skip |= LogError(
1817 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1818 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1819 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1820 i);
1821 }
1822 has_patch_control_points = true;
1823 }
1824 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1825 if (has_rasterizer_discard_enable) {
1826 skip |= LogError(
1827 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1828 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1829 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1830 i);
1831 }
1832 has_rasterizer_discard_enable = true;
1833 }
1834 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1835 if (has_depth_bias_enable) {
1836 skip |= LogError(
1837 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1838 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1839 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1840 i);
1841 }
1842 has_depth_bias_enable = true;
1843 }
1844 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1845 if (has_logic_op) {
1846 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1847 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1848 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1849 i);
1850 }
1851 has_logic_op = true;
1852 }
1853 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1854 if (has_primitive_restart_enable) {
1855 skip |= LogError(
1856 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1857 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1858 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1859 i);
1860 }
1861 has_primitive_restart_enable = true;
1862 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001863 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1864 if (has_dynamic_vertex_input) {
1865 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1866 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1867 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1868 i);
1869 }
1870 has_dynamic_vertex_input = true;
1871 }
Petr Kraus299ba622017-11-24 03:09:03 +01001872 }
1873 }
1874
sfricke-samsung3b944422021-01-23 02:15:19 -08001875 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1876 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1877 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1878 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1879 i);
1880 }
1881
1882 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1883 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1884 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1885 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1886 i);
1887 }
1888
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001889 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001890 if ((feedback_struct != nullptr) &&
1891 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001892 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1893 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1894 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1895 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1896 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001897 }
1898
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001899 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001900
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001901 // Collect active stages and other information
1902 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001903 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001904 bool has_eval = false;
1905 bool has_control = false;
1906 if (pCreateInfos[i].pStages != nullptr) {
1907 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1908 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1909
1910 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1911 has_control = true;
1912 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1913 has_eval = true;
1914 }
1915
1916 skip |= validate_string(
1917 "vkCreateGraphicsPipelines",
1918 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1919 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1920 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001921 }
1922
1923 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1924 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1925 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1926 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1927 pCreateInfos[i].pTessellationState,
1928 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1929 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1930
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001931 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001932 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1933
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001934 skip |= validate_struct_pnext(
1935 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1936 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
1937 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
1938 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
1939 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1940 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001941
1942 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1943 pCreateInfos[i].pTessellationState->flags,
1944 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1945 }
1946
1947 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1948 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1949 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1950 pCreateInfos[i].pInputAssemblyState,
1951 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1952 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1953
1954 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1955 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001956 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001957
1958 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1959 pCreateInfos[i].pInputAssemblyState->flags,
1960 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1961
1962 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1963 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1964 pCreateInfos[i].pInputAssemblyState->topology,
1965 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1966
1967 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1968 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1969 }
1970
1971 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001972 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001973
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001974 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001975 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1976 "vkCreateGraphicsPipelines: pararameter "
1977 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1978 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001979 }
1980
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001981 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001982 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1983 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1984 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1985 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001986 allowed_structs_vk_pipeline_vertex_input_state_create_info,
1987 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08001988 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001989 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1990 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001991 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001992 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1993 skip |=
1994 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1995 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1996 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1997 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1998 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1999
2000 skip |= validate_array(
2001 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2002 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2003 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2004 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2005
2006 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002007 for (uint32_t vertex_binding_description_index = 0;
2008 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2009 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002010 skip |= validate_ranged_enum(
2011 "vkCreateGraphicsPipelines",
2012 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2013 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002014 pCreateInfos[i]
2015 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2016 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002017 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2018 }
2019 }
2020
2021 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002022 for (uint32_t vertex_attribute_description_index = 0;
2023 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2024 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002025 skip |= validate_ranged_enum(
2026 "vkCreateGraphicsPipelines",
2027 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2028 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002029 pCreateInfos[i]
2030 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2031 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002032 "VUID-VkVertexInputAttributeDescription-format-parameter");
2033 }
2034 }
2035
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002036 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002037 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2038 "vkCreateGraphicsPipelines: pararameter "
2039 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2040 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2041 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002042 }
2043
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002044 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002045 skip |=
2046 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2047 "vkCreateGraphicsPipelines: pararameter "
2048 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2049 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2050 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002051 }
2052
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002053 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002054 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2055 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002056 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2057 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002058 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2059 "vkCreateGraphicsPipelines: parameter "
2060 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2061 "(%" PRIu32 ") is not distinct.",
2062 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002063 }
2064 vertex_bindings.insert(vertex_bind_desc.binding);
2065
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002066 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002067 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2068 "vkCreateGraphicsPipelines: parameter "
2069 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2070 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2071 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002072 }
2073
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002074 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002075 skip |=
2076 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2077 "vkCreateGraphicsPipelines: parameter "
2078 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2079 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2080 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002081 }
2082 }
2083
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002084 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002085 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2086 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002087 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2088 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002089 skip |= LogError(
2090 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002091 "vkCreateGraphicsPipelines: parameter "
2092 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2093 i, d, vertex_attrib_desc.location);
2094 }
2095 attribute_locations.insert(vertex_attrib_desc.location);
2096
2097 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2098 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002099 skip |= LogError(
2100 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002101 "vkCreateGraphicsPipelines: parameter "
2102 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2103 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2104 i, d, vertex_attrib_desc.binding, i);
2105 }
2106
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002107 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002108 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2109 "vkCreateGraphicsPipelines: parameter "
2110 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2111 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2112 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002113 }
2114
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002115 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002116 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2117 "vkCreateGraphicsPipelines: parameter "
2118 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2119 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2120 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002121 }
2122
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002123 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002124 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2125 "vkCreateGraphicsPipelines: parameter "
2126 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2127 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2128 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002129 }
2130 }
2131 }
2132
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002133 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2134 if (has_control && has_eval) {
2135 if (pCreateInfos[i].pTessellationState == nullptr) {
2136 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2137 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2138 "shader stage and a tessellation evaluation shader stage, "
2139 "pCreateInfos[%d].pTessellationState must not be NULL.",
2140 i, i);
2141 } else {
2142 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2143 skip |= validate_struct_pnext(
2144 "vkCreateGraphicsPipelines",
2145 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2146 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2147 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2148 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002149
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002150 skip |= validate_reserved_flags(
2151 "vkCreateGraphicsPipelines",
2152 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2153 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002154
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002155 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2156 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2157 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2158 "vkCreateGraphicsPipelines: invalid parameter "
2159 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2160 "should be >0 and <=%u.",
2161 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2162 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002163 }
2164 }
2165 }
2166
2167 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2168 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2169 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2170 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002171 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2172 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2173 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2174 "].pViewportState (=NULL) is not a valid pointer.",
2175 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002176 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002177 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2178
2179 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002180 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2181 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2182 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2183 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002184 }
2185
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002186 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002187 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002188 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2189 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002190 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2191 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002192 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002193 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002194 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002195 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002196 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002197 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2198 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002199 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2200 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2201 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002202 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002203
2204 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002205 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002206 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002207 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002208
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002209 auto exclusive_scissor_struct =
2210 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2211 auto shading_rate_image_struct =
2212 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2213 auto coarse_sample_order_struct =
2214 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002215 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002216 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002217 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002218 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002219
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002220 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002221 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002222 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2223 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2224 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2225 ") is not 1.",
2226 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002227 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002228
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002229 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002230 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2231 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2232 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2233 ") is not 1.",
2234 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002235 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002236
Dave Houlton142c4cb2018-10-17 15:04:41 -06002237 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2238 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002239 skip |= LogError(
2240 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2241 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2242 "disabled, but pCreateInfos[%" PRIu32
2243 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2244 ") is not 1.",
2245 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002246 }
2247
Jeff Bolz9af91c52018-09-01 21:53:57 -05002248 if (shading_rate_image_struct &&
2249 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002250 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2251 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2252 "disabled, but pCreateInfos[%" PRIu32
2253 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2254 ") is neither 0 nor 1.",
2255 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002256 }
2257
Petr Krausa6103552017-11-16 21:21:58 +01002258 } else { // multiViewport enabled
2259 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002260 if (!has_dynamic_viewport_with_count) {
2261 skip |= LogError(
2262 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2263 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2264 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002265 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002266 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2267 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2268 "].pViewportState->viewportCount (=%" PRIu32
2269 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2270 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002271 } else if (has_dynamic_viewport_with_count) {
2272 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2273 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2274 "].pViewportState->viewportCount (=%" PRIu32
2275 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2276 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002277 }
Petr Krausa6103552017-11-16 21:21:58 +01002278
2279 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002280 if (!has_dynamic_scissor_with_count) {
2281 skip |= LogError(
2282 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2283 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2284 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002285 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002286 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2287 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2288 "].pViewportState->scissorCount (=%" PRIu32
2289 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2290 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002291 } else if (has_dynamic_scissor_with_count) {
2292 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2293 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2294 "].pViewportState->scissorCount (=%" PRIu32
2295 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2296 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002297 }
2298 }
2299
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002300 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002301 skip |=
2302 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2303 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2304 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2305 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002306 }
2307
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002308 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002309 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2310 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2311 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2312 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2313 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002314 }
2315
Piers Daniell39842ee2020-07-10 16:42:33 -06002316 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2317 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002318 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2319 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2320 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2321 "].pViewportState->viewportCount (=%" PRIu32 ").",
2322 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002323 }
2324
Dave Houlton142c4cb2018-10-17 15:04:41 -06002325 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002326 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002327 skip |=
2328 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2329 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2330 ") must be zero or identical to pCreateInfos[%" PRIu32
2331 "].pViewportState->viewportCount (=%" PRIu32 ").",
2332 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002333 }
2334
Dave Houlton142c4cb2018-10-17 15:04:41 -06002335 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002336 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002337 skip |= LogError(
2338 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002339 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2340 "] "
2341 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2342 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2343 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002344 }
2345
Petr Krausa6103552017-11-16 21:21:58 +01002346 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002347 skip |= LogError(
2348 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002349 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2350 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002351 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2352 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002353 }
2354
2355 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002356 skip |= LogError(
2357 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002358 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2359 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002360 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2361 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002362 }
2363
Jeff Bolz3e71f782018-08-29 23:15:45 -05002364 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002365 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2366 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2367 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002368 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002369 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2370 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2371 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2372 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002373 }
2374
Jeff Bolz9af91c52018-09-01 21:53:57 -05002375 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002376 shading_rate_image_struct->viewportCount > 0 &&
2377 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002378 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002379 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002380 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002381 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2382 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002383 i, i);
2384 }
2385
Chris Mayer328d8212018-12-11 14:16:18 +01002386 if (vp_swizzle_struct) {
2387 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002388 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2389 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2390 " does "
2391 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2392 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002393 }
2394 }
2395
Petr Krausb3fcdb42018-01-09 22:09:09 +01002396 // validate the VkViewports
2397 if (!has_dynamic_viewport && viewport_state.pViewports) {
2398 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2399 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002400 const char *fn_name = "vkCreateGraphicsPipelines";
2401 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2402 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2403 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002404 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002405 }
2406 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002407
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002408 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002409 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2410 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2411 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2412 "VK_NV_clip_space_w_scaling extension is not enabled.",
2413 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002414 }
2415
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002416 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002417 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2418 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2419 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2420 "VK_EXT_discard_rectangles extension is not enabled.",
2421 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002422 }
2423
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002424 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002425 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2426 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2427 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2428 "VK_EXT_sample_locations extension is not enabled.",
2429 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002430 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002431
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002432 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002433 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2434 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2435 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2436 "VK_NV_scissor_exclusive extension is not enabled.",
2437 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002438 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002439
2440 if (coarse_sample_order_struct &&
2441 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2442 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002443 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2444 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2445 "] "
2446 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2447 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2448 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002449 }
2450
2451 if (coarse_sample_order_struct) {
2452 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002453 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002454 }
2455 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002456
2457 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2458 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002459 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2460 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2461 "] "
2462 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2463 ") "
2464 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2465 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002466 }
2467 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002468 skip |= LogError(
2469 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002470 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2471 "] "
2472 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2473 i);
2474 }
2475 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002476 }
2477
2478 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002479 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2480 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2481 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2482 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002483 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002484 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002485 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002486 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2487 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002488 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002489 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002490 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002491 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002492 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002493 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002494 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002495 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2496 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002497
2498 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002499 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002500 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002501 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002502
2503 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002504 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002505 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2506 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2507
2508 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002509 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002510 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2511 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002512 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002513 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002514
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002515 skip |= validate_flags(
2516 "vkCreateGraphicsPipelines",
2517 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2518 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002519 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002520
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002521 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002522 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002523 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2524 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2525
2526 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002527 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002528 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2529 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2530
2531 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002532 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002533 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2534 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2535 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002536 }
John Zulauf7acac592017-11-06 11:15:53 -07002537 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002538 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002539 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2540 "vkCreateGraphicsPipelines(): parameter "
2541 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2542 i);
John Zulauf7acac592017-11-06 11:15:53 -07002543 }
2544 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2545 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2546 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002547 skip |= LogError(
2548 device,
2549
Dave Houlton413a6782018-05-22 13:01:54 -06002550 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002551 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002552 }
2553 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002554
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002555 const auto *line_state =
2556 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002557
2558 if (line_state) {
2559 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2560 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2561 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2562 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002563 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2564 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2565 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2566 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002567 }
2568 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2569 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002570 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2571 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2572 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2573 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002574 }
2575 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2576 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002577 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2578 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2579 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2580 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002581 }
2582 }
2583 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2584 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2585 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002586 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2587 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2588 "range [1,256].",
2589 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002590 }
2591 }
2592 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002593 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002594 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2595 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002596 skip |=
2597 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2598 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2599 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2600 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002601 }
2602 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2603 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002604 skip |=
2605 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2606 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2607 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2608 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002609 }
2610 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2611 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002612 skip |=
2613 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2614 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2615 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2616 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002617 }
2618 if (line_state->stippledLineEnable) {
2619 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2620 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002621 skip |=
2622 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2623 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2624 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2625 "stippledRectangularLines feature.",
2626 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002627 }
2628 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2629 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002630 skip |=
2631 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2632 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2633 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2634 "stippledBresenhamLines feature.",
2635 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002636 }
2637 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2638 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002639 skip |=
2640 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2641 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2642 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2643 "stippledSmoothLines feature.",
2644 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002645 }
2646 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2647 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002648 skip |=
2649 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2650 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2651 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2652 "stippledRectangularLines and strictLines features.",
2653 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002654 }
2655 }
2656 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002657 }
2658
Petr Krause91f7a12017-12-14 20:57:36 +01002659 bool uses_color_attachment = false;
2660 bool uses_depthstencil_attachment = false;
2661 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002662 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002663 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2664 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002665 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002666 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002667 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002668 }
2669 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002670 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002671 }
Petr Krause91f7a12017-12-14 20:57:36 +01002672 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002673 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002674 }
2675
2676 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002677 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002678 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002679 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002680 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002681 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002682
2683 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002684 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002685 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002686 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002687
2688 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002689 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002690 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2691 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2692
2693 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002694 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002695 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2696 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2697
2698 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002699 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002700 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2701 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002702 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002703
2704 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002705 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002706 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2707 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2708
2709 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002710 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002711 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2712 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2713
2714 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002715 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002716 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2717 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002718 "VUID-VkStencilOpState-failOp-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].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2723 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002724 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002725
2726 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002727 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002728 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2729 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002730 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002731
2732 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002733 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002734 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2735 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002736 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002737
2738 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002739 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002740 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2741 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002742 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002743
2744 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002745 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002746 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2747 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002748 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002749
2750 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002751 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002752 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2753 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002754 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002755
2756 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002757 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002758 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2759 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002760 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002761
2762 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002763 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002764 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2765 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2766 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002767 }
2768 }
2769
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002770 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002771 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2772
Petr Krause91f7a12017-12-14 20:57:36 +01002773 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002774 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2775 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2776 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2777 pCreateInfos[i].pColorBlendState,
2778 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2779 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2780
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002781 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002782 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002783 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2784 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002785 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2786 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002787 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2788 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002789
2790 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002791 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002792 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002793 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002794
2795 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002796 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002797 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2798 pCreateInfos[i].pColorBlendState->logicOpEnable);
2799
2800 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002801 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2803 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002804 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002805 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002806
2807 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002808 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2809 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002810 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002811 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002812 ParameterName::IndexVector{i, attachment_index}),
2813 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002814
2815 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002816 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002817 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002818 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002819 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002820 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002821 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822
2823 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002824 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002825 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002826 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002827 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002828 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002829 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830
2831 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002832 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002833 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002834 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002836 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002837 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002838
2839 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002840 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002841 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002842 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002843 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002844 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002845 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002846
2847 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002848 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002849 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002850 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002851 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002852 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002853 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002854
2855 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002856 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002857 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002858 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002859 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002860 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002861 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002862
2863 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002864 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002865 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002866 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002868 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002869 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870 }
2871 }
2872
2873 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002874 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002875 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2876 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2877 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002878 }
2879
2880 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2881 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2882 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002883 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002884 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002885 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2886 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002887 }
2888 }
2889 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002890
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002891 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
2892 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01002893 if (pCreateInfos[i].basePipelineIndex != -1) {
2894 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002895 skip |=
2896 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002897 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002898 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002899 "and pCreateInfos->basePipelineIndex is not -1.",
2900 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002901 }
2902 }
2903
Petr Kraus9752aae2017-11-24 03:05:50 +01002904 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2905 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002906 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002907 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002908 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002909 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2910 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002911 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002912 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002913 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002914 skip |=
2915 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2916 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2917 "index into the pCreateInfos array, of size %d.",
2918 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002919 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002920 }
2921 }
2922
Petr Kraus9752aae2017-11-24 03:05:50 +01002923 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002924 if (!device_extensions.vk_nv_fill_rectangle) {
2925 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2926 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002927 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2928 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2929 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2930 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002931 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2932 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07002933 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002934 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002935 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2936 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2937 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002938 }
2939 } else {
2940 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2941 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2942 (physical_device_features.fillModeNonSolid == false)) {
2943 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002944 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2945 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002946 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2947 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2948 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002949 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002950 }
Petr Kraus299ba622017-11-24 03:09:03 +01002951
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002952 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002953 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002954 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2955 "The line width state is static (pCreateInfos[%" PRIu32
2956 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2957 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2958 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2959 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002960 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002961 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002962
2963 // Validate no flags not allowed are used
2964 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07002965 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2966 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2967 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
2968 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002969 }
2970 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07002971 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
2972 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2973 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
2974 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002975 }
2976 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
2977 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07002978 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2979 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
2980 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002981 }
2982 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
2983 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07002984 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2985 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
2986 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002987 }
2988 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
2989 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07002990 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2991 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
2992 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002993 }
2994 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
2995 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07002996 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2997 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
2998 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002999 }
3000 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3001 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003002 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3003 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3004 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003005 }
3006 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3007 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003008 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3009 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3010 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003011 }
3012 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3013 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003014 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3015 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3016 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003017 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003018 }
3019 }
3020
3021 return skip;
3022}
3023
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003024bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3025 uint32_t createInfoCount,
3026 const VkComputePipelineCreateInfo *pCreateInfos,
3027 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003028 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003029 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003030 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003031 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003032 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003033 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003034 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003035 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003036 skip |=
3037 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3038 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3039 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3040 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003041 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003042
3043 // Make sure compute stage is selected
3044 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003045 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3046 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3047 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003048 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003049
sfricke-samsungeb549012021-04-16 01:25:51 -07003050 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3051 // Validate no flags not allowed are used
3052 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3053 skip |= LogError(
3054 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3055 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3056 i, flags);
3057 }
3058 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3059 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3060 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3061 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3062 i, flags);
3063 }
3064 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3065 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3066 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3067 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3068 i, flags);
3069 }
3070 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3071 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3072 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3073 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3074 i, flags);
3075 }
3076 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3077 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3078 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3079 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3080 i, flags);
3081 }
3082 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3083 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3084 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3085 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3086 i, flags);
3087 }
3088 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3089 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3090 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3091 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3092 i, flags);
3093 }
3094 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3095 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3096 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3097 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3098 i, flags);
3099 }
3100 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3101 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3102 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3103 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3104 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003105 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003106 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003107 return skip;
3108}
3109
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003110bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003111 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003112 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003113
3114 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003115 const auto &features = physical_device_features;
3116 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003117
John Zulauf71968502017-10-26 13:51:15 -06003118 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3119 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003120 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3121 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3122 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3123 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003124 }
3125
3126 // Anistropy cannot be enabled in sampler unless enabled as a feature
3127 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003128 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3129 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3130 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003131 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003132 }
John Zulauf71968502017-10-26 13:51:15 -06003133
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003134 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3135 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003136 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3137 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3138 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3139 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003140 }
3141 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003142 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3143 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3144 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3145 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003146 }
3147 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003148 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3149 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3150 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3151 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003152 }
3153 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3154 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3155 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3156 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003157 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3158 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3159 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3160 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3161 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3162 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003163 }
3164 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003165 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3166 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3167 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003168 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003169 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003170 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3171 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3172 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003173 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003174 }
3175
3176 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3177 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003178 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3179 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003180 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003181 if (sampler_reduction != nullptr) {
3182 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3183 skip |= LogError(
3184 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3185 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3186 }
3187 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003188 }
3189
3190 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3191 // valid VkBorderColor value
3192 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3193 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3194 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003195 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3196 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003197 }
3198
3199 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
3200 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003201 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003202 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
3203 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
3204 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06003205 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003206 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
3207 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
3208 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003209 }
John Zulauf275805c2017-10-26 15:34:49 -06003210
3211 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003212 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003213 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3214 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003215 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3216 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3217 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003218 }
3219 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003220
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003221 // Check for valid Lod range
3222 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003223 skip |=
3224 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3225 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003226 }
3227
3228 // Check mipLodBias to device limit
3229 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003230 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3231 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3232 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003233 }
3234
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003235 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003236 if (sampler_conversion != nullptr) {
3237 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3238 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3239 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3240 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003241 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003242 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003243 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3244 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3245 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3246 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3247 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3248 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3249 }
3250 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003251
3252 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3253 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3254 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3255 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3256 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3257 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3258 }
3259 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3260 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3261 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3262 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3263 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3264 }
3265 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3266 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3267 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3268 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3269 pCreateInfo->minLod, pCreateInfo->maxLod);
3270 }
3271 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3272 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3273 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3274 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3275 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3276 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3277 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3278 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3279 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3280 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3281 }
3282 if (pCreateInfo->anisotropyEnable) {
3283 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3284 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3285 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3286 }
3287 if (pCreateInfo->compareEnable) {
3288 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3289 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3290 "pCreateInfo->compareEnable must be VK_FALSE");
3291 }
3292 if (pCreateInfo->unnormalizedCoordinates) {
3293 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3294 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3295 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3296 }
3297 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003298 }
3299
Tony-LunarG7337b312020-04-15 16:40:25 -06003300 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3301 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3302 if (!device_extensions.vk_ext_custom_border_color) {
3303 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3304 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3305 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3306 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003307 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003308 if (!custom_create_info) {
3309 skip |=
3310 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3311 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3312 "struct in pNext chain.\n",
3313 string_VkBorderColor(pCreateInfo->borderColor));
3314 } else {
3315 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3316 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3317 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3318 !FormatIsSampledFloat(custom_create_info->format)))) {
3319 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3320 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3321 "whose type does not match\n",
3322 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3323 ;
3324 }
3325 }
3326 }
3327
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003328 return skip;
3329}
3330
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003331bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3332 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3333 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003334 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003335 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003336
3337 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3338 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3339 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3340 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003341 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3342 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3343 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3344 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3345 ++descriptor_index) {
3346 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003347 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003348 "vkCreateDescriptorSetLayout: required parameter "
3349 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3350 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003351 }
3352 }
3353 }
3354
3355 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3356 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3357 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003358 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3359 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3360 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3361 "values.",
3362 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003363 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003364
3365 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3366 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3367 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3368 skip |=
3369 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3370 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3371 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3372 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3373 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3374 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003375 }
3376 }
3377 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003378 return skip;
3379}
3380
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003381bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3382 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003383 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003384 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3385 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3386 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003387 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3388 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003389}
3390
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003391bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3392 const VkWriteDescriptorSet *pDescriptorWrites,
3393 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003394 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003395
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003396 if (pDescriptorWrites != NULL) {
3397 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3398 // descriptorCount must be greater than 0
3399 if (pDescriptorWrites[i].descriptorCount == 0) {
3400 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003401 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3402 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003403 }
3404
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003405 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3406 if (validateDstSet) {
3407 // dstSet must be a valid VkDescriptorSet handle
3408 skip |= validate_required_handle(vkCallingFunction,
3409 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3410 pDescriptorWrites[i].dstSet);
3411 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003412
3413 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3414 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3415 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3416 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3417 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3418 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3419 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003420 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3421 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003422 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003423 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3424 "%s(): if pDescriptorWrites[%d].descriptorType is "
3425 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3426 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3427 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3428 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003429 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3430 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003431 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3432 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3434 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003435 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003436 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3437 ParameterName::IndexVector{i, descriptor_index}),
3438 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003439 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003440 }
3441 }
3442 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3443 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3444 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3445 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3446 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3447 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3448 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003449 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003450 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003451 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3452 "%s(): if pDescriptorWrites[%d].descriptorType is "
3453 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3454 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3455 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3456 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003457 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003458 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003459 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003460 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003461 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3462 ++descriptor_index) {
3463 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3464 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3465 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003466 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3467 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003468 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003469 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3470 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003471 }
3472 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003473 }
3474 }
3475 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3476 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003477 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003478 }
3479
3480 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3481 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003482 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003483 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3484 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003485 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003486 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003487 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3488 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3489 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003490 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003491 }
3492 }
3493 }
3494 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3495 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003496 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003497 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3498 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003499 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003500 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003501 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3502 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3503 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003504 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003505 }
3506 }
3507 }
3508 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003509 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3510 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003511 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003512 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003513 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3514 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3515 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3516 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3517 "accelerationStructureCount %d member equals descriptorCount %d.",
3518 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3519 pDescriptorWrites[i].descriptorCount);
3520 }
3521 // further checks only if we have right structtype
3522 if (pnext_struct) {
3523 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3524 skip |= LogError(
3525 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3526 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3527 ".",
3528 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003529 }
sourav parmarbcee7512020-12-28 14:34:49 -08003530 if (pnext_struct->accelerationStructureCount == 0) {
3531 skip |= LogError(device,
3532 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3533 "%s(): accelerationStructureCount must be greater than 0 .");
3534 }
3535 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003536 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003537 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3538 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3539 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3540 skip |= LogError(device,
3541 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3542 "%s(): If the nullDescriptor feature is not enabled, each member of "
3543 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003544 }
3545 }
3546 }
sourav parmarbcee7512020-12-28 14:34:49 -08003547 }
3548 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003549 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003550 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3551 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3552 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3553 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3554 "accelerationStructureCount %d member equals descriptorCount %d.",
3555 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3556 pDescriptorWrites[i].descriptorCount);
3557 }
3558 // further checks only if we have right structtype
3559 if (pnext_struct) {
3560 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3561 skip |= LogError(
3562 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3563 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3564 ".",
3565 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003566 }
sourav parmarbcee7512020-12-28 14:34:49 -08003567 if (pnext_struct->accelerationStructureCount == 0) {
3568 skip |= LogError(device,
3569 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
3570 "%s(): accelerationStructureCount must be greater than 0 .");
3571 }
3572 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003573 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003574 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3575 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3576 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3577 skip |= LogError(device,
3578 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3579 "%s(): If the nullDescriptor feature is not enabled, each member of "
3580 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003581 }
3582 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003583 }
3584 }
3585 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003586 }
3587 }
3588 return skip;
3589}
3590
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003591bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3592 const VkWriteDescriptorSet *pDescriptorWrites,
3593 uint32_t descriptorCopyCount,
3594 const VkCopyDescriptorSet *pDescriptorCopies) const {
3595 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3596}
3597
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003598bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003599 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003600 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003601 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3602}
3603
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003604bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3605 const VkAllocationCallbacks *pAllocator,
3606 VkRenderPass *pRenderPass) const {
3607 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3608}
3609
Mike Schuchardt2df08912020-12-15 16:28:09 -08003610bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003611 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003612 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003613 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3614}
3615
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003616bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3617 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003618 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003619 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003620
3621 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3622 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3623 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003624 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3625 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003626 return skip;
3627}
3628
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003629bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003630 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003631 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003632
3633 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3634 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003635 bool cb_is_secondary;
3636 {
3637 auto lock = cb_read_lock();
3638 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3639 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003640
Tony-LunarG3c287f62020-12-17 12:39:49 -07003641 if (cb_is_secondary) {
3642 // Implicit VUs
3643 // validate only sType here; pointer has to be validated in core_validation
3644 const bool k_not_required = false;
3645 const char *k_no_vuid = nullptr;
3646 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3647 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003648 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3649 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003650
Tony-LunarG3c287f62020-12-17 12:39:49 -07003651 if (info) {
3652 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003653 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3654 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003655 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003656 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3657 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3658 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3659 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003660
Tony-LunarG3c287f62020-12-17 12:39:49 -07003661 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003662
Tony-LunarG3c287f62020-12-17 12:39:49 -07003663 // Explicit VUs
3664 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003665 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003666 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3667 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3668 cmd_name);
3669 }
3670
3671 if (physical_device_features.inheritedQueries) {
3672 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003673 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3674 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3675 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003676 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003677 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003678 }
3679
3680 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003681 skip |=
3682 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3683 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3684 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3685 } else { // !pipelineStatisticsQuery
3686 skip |=
3687 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3688 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003689 }
3690
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003691 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003692 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003693 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003694 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3695 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3696 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003697 commandBuffer,
3698 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003699 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3700 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3701 }
Petr Kraus139757b2019-08-15 17:19:33 +02003702 }
3703 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003704 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003705 return skip;
3706}
3707
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003708bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003709 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003710 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003711
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003712 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003713 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003714 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3715 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3716 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003717 }
3718 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003719 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3720 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3721 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003722 }
3723 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003724 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003725 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003726 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3727 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3728 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3729 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003730 }
3731 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003732
3733 if (pViewports) {
3734 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3735 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003736 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003737 skip |= manual_PreCallValidateViewport(
3738 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003739 }
3740 }
3741
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003742 return skip;
3743}
3744
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003745bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003746 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003747 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003748
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003749 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003750 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003751 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3752 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3753 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003754 }
3755 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003756 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3757 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3758 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003759 }
3760 } else { // multiViewport enabled
3761 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003762 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003763 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3764 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3765 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3766 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003767 }
3768 }
3769
Petr Kraus6260f0a2018-02-27 21:15:55 +01003770 if (pScissors) {
3771 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3772 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003773
Petr Kraus6260f0a2018-02-27 21:15:55 +01003774 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003775 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3776 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3777 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003778 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003779
Petr Kraus6260f0a2018-02-27 21:15:55 +01003780 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003781 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3782 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3783 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003784 }
3785
3786 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3787 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003788 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3789 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3790 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3791 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003792 }
3793
3794 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3795 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003796 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3797 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3798 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3799 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003800 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003801 }
3802 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003803
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003804 return skip;
3805}
3806
Jeff Bolz5c801d12019-10-09 10:38:45 -05003807bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003808 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003809
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003810 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003811 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3812 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003813 }
3814
3815 return skip;
3816}
3817
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003818bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003819 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003820 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003821
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003822 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003823 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003824 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3825 }
3826 if (drawCount > device_limits.maxDrawIndirectCount) {
3827 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003828 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3829 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003830 }
3831 return skip;
3832}
3833
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003834bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003835 VkDeviceSize offset, uint32_t drawCount,
3836 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003837 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003838 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003839 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3840 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3841 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003842 }
3843 if (drawCount > device_limits.maxDrawIndirectCount) {
3844 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003845 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3846 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003847 }
3848 return skip;
3849}
3850
sfricke-samsungf692b972020-05-02 08:00:45 -07003851bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3852 VkDeviceSize countBufferOffset, bool khr) const {
3853 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003854 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003855 if (offset & 3) {
3856 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003857 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003858 }
3859
3860 if (countBufferOffset & 3) {
3861 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003862 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003863 countBufferOffset);
3864 }
3865 return skip;
3866}
3867
3868bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3869 VkDeviceSize offset, VkBuffer countBuffer,
3870 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3871 uint32_t stride) const {
3872 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3873}
3874
3875bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3876 VkDeviceSize offset, VkBuffer countBuffer,
3877 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3878 uint32_t stride) const {
3879 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3880}
3881
3882bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3883 VkDeviceSize countBufferOffset, bool khr) const {
3884 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003885 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003886 if (offset & 3) {
3887 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003888 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003889 }
3890
3891 if (countBufferOffset & 3) {
3892 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003893 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003894 countBufferOffset);
3895 }
3896 return skip;
3897}
3898
3899bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3900 VkDeviceSize offset, VkBuffer countBuffer,
3901 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3902 uint32_t stride) const {
3903 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3904}
3905
3906bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3907 VkDeviceSize offset, VkBuffer countBuffer,
3908 VkDeviceSize countBufferOffset,
3909 uint32_t maxDrawCount, uint32_t stride) const {
3910 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3911}
3912
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003913bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3914 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003915 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003916 bool skip = false;
3917 for (uint32_t rect = 0; rect < rectCount; rect++) {
3918 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003919 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3920 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003921 }
sfricke-samsung10867682020-04-25 02:20:39 -07003922 if (pRects[rect].rect.extent.width == 0) {
3923 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3924 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3925 }
3926 if (pRects[rect].rect.extent.height == 0) {
3927 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3928 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3929 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003930 }
3931 return skip;
3932}
3933
Andrew Fobel3abeb992020-01-20 16:33:22 -05003934bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3935 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3936 VkImageFormatProperties2 *pImageFormatProperties,
3937 const char *apiName) const {
3938 bool skip = false;
3939
3940 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003941 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003942 if (image_stencil_struct != nullptr) {
3943 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3944 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3945 // No flags other than the legal attachment bits may be set
3946 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3947 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003948 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3949 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3950 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3951 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3952 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003953 }
3954 }
3955 }
3956 }
3957
3958 return skip;
3959}
3960
3961bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3962 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3963 VkImageFormatProperties2 *pImageFormatProperties) const {
3964 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3965 "vkGetPhysicalDeviceImageFormatProperties2");
3966}
3967
3968bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3969 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3970 VkImageFormatProperties2 *pImageFormatProperties) const {
3971 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3972 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3973}
3974
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03003975bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
3976 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
3977 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
3978 bool skip = false;
3979
3980 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
3981 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
3982 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
3983 }
3984
3985 return skip;
3986}
3987
sfricke-samsung3999ef62020-02-09 17:05:59 -08003988bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3989 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3990 bool skip = false;
3991
3992 if (pRegions != nullptr) {
3993 for (uint32_t i = 0; i < regionCount; i++) {
3994 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003995 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3996 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003997 }
3998 }
3999 }
4000 return skip;
4001}
4002
Jeff Leger178b1e52020-10-05 12:22:23 -04004003bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4004 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4005 bool skip = false;
4006
4007 if (pCopyBufferInfo->pRegions != nullptr) {
4008 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4009 if (pCopyBufferInfo->pRegions[i].size == 0) {
4010 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4011 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4012 }
4013 }
4014 }
4015 return skip;
4016}
4017
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004018bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004019 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4020 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004021 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004022
4023 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004024 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4025 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4026 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004027 }
4028
4029 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004030 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4031 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4032 "), must be greater than zero and less than or equal to 65536.",
4033 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004034 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004035 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4036 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4037 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004038 }
4039 return skip;
4040}
4041
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004042bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004043 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004044 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004045
4046 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004047 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4048 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4049 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004050 }
4051
4052 if (size != VK_WHOLE_SIZE) {
4053 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004054 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004055 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4056 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004057 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004058 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4059 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004060 }
4061 }
4062 return skip;
4063}
4064
sfricke-samsunga1d00272021-03-10 21:37:41 -08004065bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004066 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004067
4068 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004069 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4070 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4071 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4072 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004073 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004074 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4075 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4076 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004077 }
4078
4079 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4080 // queueFamilyIndexCount uint32_t values
4081 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004082 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004083 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004084 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004085 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4086 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004087 }
4088 }
4089
Dave Houlton413a6782018-05-22 13:01:54 -06004090 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004091 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004092
sfricke-samsunga1d00272021-03-10 21:37:41 -08004093 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4094 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4095 if (format_list_info) {
4096 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4097 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4098 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4099 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4100 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4101 func_name, viewFormatCount);
4102 }
4103
4104 // Using the first format, compare the rest of the formats against it that they are compatible
4105 for (uint32_t i = 1; i < viewFormatCount; i++) {
4106 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4107 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4108 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4109 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4110 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4111 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4112 string_VkFormat(format_list_info->pViewFormats[i]));
4113 }
4114 }
4115 }
4116
4117 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4118 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4119 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4120 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4121 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4122 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4123 func_name);
4124 } else {
4125 if (format_list_info == nullptr) {
4126 skip |= LogError(
4127 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4128 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4129 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4130 func_name);
4131 } else if (format_list_info->viewFormatCount == 0) {
4132 skip |= LogError(
4133 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4134 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4135 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4136 func_name);
4137 } else {
4138 bool found_base_format = false;
4139 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4140 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4141 found_base_format = true;
4142 break;
4143 }
4144 }
4145 if (!found_base_format) {
4146 skip |=
4147 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4148 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4149 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4150 "pCreateInfo->imageFormat.",
4151 func_name);
4152 }
4153 }
4154 }
4155 }
4156 }
4157 return skip;
4158}
4159
4160bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4161 const VkAllocationCallbacks *pAllocator,
4162 VkSwapchainKHR *pSwapchain) const {
4163 bool skip = false;
4164 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4165 return skip;
4166}
4167
4168bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4169 const VkSwapchainCreateInfoKHR *pCreateInfos,
4170 const VkAllocationCallbacks *pAllocator,
4171 VkSwapchainKHR *pSwapchains) const {
4172 bool skip = false;
4173 if (pCreateInfos) {
4174 for (uint32_t i = 0; i < swapchainCount; i++) {
4175 std::stringstream func_name;
4176 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4177 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4178 }
4179 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004180 return skip;
4181}
4182
Jeff Bolz5c801d12019-10-09 10:38:45 -05004183bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004184 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004185
4186 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004187 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004188 if (present_regions) {
4189 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004190 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004191 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4192 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004193 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004194 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4195 "extension swapchainCount is %i. These values must be equal.",
4196 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004197 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004198 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004199 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4200 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004201 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4202 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4203 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004204 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004205 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004206 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004207 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004208 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004209 }
4210 }
4211
4212 return skip;
4213}
4214
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004215bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4216 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4217 const VkAllocationCallbacks *pAllocator,
4218 VkDisplayModeKHR *pMode) const {
4219 bool skip = false;
4220
4221 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4222 if (display_mode_parameters.visibleRegion.width == 0) {
4223 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4224 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4225 }
4226 if (display_mode_parameters.visibleRegion.height == 0) {
4227 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4228 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4229 }
4230 if (display_mode_parameters.refreshRate == 0) {
4231 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4232 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4233 }
4234
4235 return skip;
4236}
4237
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004238#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004239bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4240 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4241 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004242 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004243 bool skip = false;
4244
4245 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004246 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4247 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004248 }
4249
4250 return skip;
4251}
4252#endif // VK_USE_PLATFORM_WIN32_KHR
4253
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004254bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004255 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004256 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004257 bool skip = false;
4258
4259 if (pCreateInfo) {
4260 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004261 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4262 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004263 }
4264
4265 if (pCreateInfo->pPoolSizes) {
4266 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4267 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004268 skip |= LogError(
4269 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004270 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004271 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004272 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4273 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004274 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4275 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4276 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4277 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4278 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004279 }
Petr Krausc8655be2017-09-27 18:56:51 +02004280 }
4281 }
4282 }
4283
4284 return skip;
4285}
4286
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004287bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004288 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004289 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004290
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004291 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004292 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004293 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4294 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4295 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004296 }
4297
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004298 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004299 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004300 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4301 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4302 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004303 }
4304
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004305 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004306 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004307 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4308 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4309 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004310 }
4311
4312 return skip;
4313}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004314
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004315bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004316 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004317 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004318
4319 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004320 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4321 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004322 }
4323 return skip;
4324}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004325
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004326bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4327 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004328 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004329 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004330
4331 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004332 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004333 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004334 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4335 "vkCmdDispatch(): baseGroupX (%" PRIu32
4336 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4337 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004338 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004339 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4340 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4341 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4342 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004343 }
4344
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004345 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004346 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004347 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4348 "vkCmdDispatch(): baseGroupY (%" PRIu32
4349 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4350 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004351 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004352 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4353 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4354 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4355 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004356 }
4357
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004358 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004359 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004360 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4361 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4362 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4363 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004364 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004365 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4366 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4367 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4368 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004369 }
4370
4371 return skip;
4372}
4373
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004374bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4375 VkPipelineBindPoint pipelineBindPoint,
4376 VkPipelineLayout layout, uint32_t set,
4377 uint32_t descriptorWriteCount,
4378 const VkWriteDescriptorSet *pDescriptorWrites) const {
4379 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4380}
4381
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004382bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4383 uint32_t firstExclusiveScissor,
4384 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004385 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004386 bool skip = false;
4387
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004388 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004389 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004390 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004391 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4392 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4393 ") is not 0.",
4394 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004395 }
4396 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004397 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004398 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4399 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4400 ") is not 1.",
4401 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004402 }
4403 } else { // multiViewport enabled
4404 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004405 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004406 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4407 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4408 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4409 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004410 }
4411 }
4412
Jeff Bolz3e71f782018-08-29 23:15:45 -05004413 if (pExclusiveScissors) {
4414 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4415 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4416
4417 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004418 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4419 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4420 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004421 }
4422
4423 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004424 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4425 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4426 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004427 }
4428
4429 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4430 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004431 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4432 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4433 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4434 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004435 }
4436
4437 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4438 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004439 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4440 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4441 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4442 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004443 }
4444 }
4445 }
4446
4447 return skip;
4448}
4449
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004450bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4451 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004452 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004453 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004454 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4455 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4456 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4457 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4458 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4459 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004460 }
4461
4462 return skip;
4463}
4464
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004465bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4466 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004467 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004468 bool skip = false;
4469
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004470 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004471 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004472 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004473 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4474 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4475 ") is not 0.",
4476 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004477 }
4478 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004479 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004480 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4481 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4482 ") is not 1.",
4483 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004484 }
4485 }
4486
Jeff Bolz9af91c52018-09-01 21:53:57 -05004487 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004488 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004489 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4490 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4491 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4492 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004493 }
4494
4495 return skip;
4496}
4497
Jeff Bolz5c801d12019-10-09 10:38:45 -05004498bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4499 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4500 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004501 bool skip = false;
4502
Dave Houlton142c4cb2018-10-17 15:04:41 -06004503 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004504 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4505 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4506 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004507 }
4508
4509 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004510 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004511 }
4512
4513 return skip;
4514}
4515
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004516bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004517 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004518 bool skip = false;
4519
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004520 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004521 skip |= LogError(
4522 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004523 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4524 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004525 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004526 }
4527
4528 return skip;
4529}
4530
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004531bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4532 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004533 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004534 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004535 static const int condition_multiples = 0b0011;
4536 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004537 skip |= LogError(
4538 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004539 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004540 }
Lockee1c22882019-06-10 16:02:54 -06004541 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004542 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4543 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4544 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4545 stride);
Lockee1c22882019-06-10 16:02:54 -06004546 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004547 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004548 skip |= LogError(
4549 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4550 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004551 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004552 if (drawCount > device_limits.maxDrawIndirectCount) {
4553 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004554 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4555 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004556 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004557 return skip;
4558}
4559
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004560bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4561 VkDeviceSize offset, VkBuffer countBuffer,
4562 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004563 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004564 bool skip = false;
4565
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004566 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004567 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4568 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4569 "), is not a multiple of 4.",
4570 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004571 }
4572
4573 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004574 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4575 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4576 "), is not a multiple of 4.",
4577 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004578 }
4579
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004580 return skip;
4581}
4582
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004583bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004584 const VkAllocationCallbacks *pAllocator,
4585 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004586 bool skip = false;
4587
4588 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4589 if (pCreateInfo != nullptr) {
4590 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4591 // VkQueryPipelineStatisticFlagBits values
4592 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4593 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004594 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4595 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4596 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4597 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004598 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004599 if (pCreateInfo->queryCount == 0) {
4600 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4601 "vkCreateQueryPool(): queryCount must be greater than zero.");
4602 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004603 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004604 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004605}
4606
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004607bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4608 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004609 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004610 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4611 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004612}
4613
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004614void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004615 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4616 VkResult result) {
4617 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004618 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004619}
4620
Mike Schuchardt2df08912020-12-15 16:28:09 -08004621void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004622 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4623 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004624 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004625 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004626 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004627}
4628
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004629void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4630 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004631 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004632 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004633 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004634}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004635
Tony-LunarG3c287f62020-12-17 12:39:49 -07004636void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004637 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004638 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4639 auto lock = cb_write_lock();
4640 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004641 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004642 }
4643 }
4644}
4645
4646void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004647 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004648 auto lock = cb_write_lock();
4649 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4650 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4651 }
4652}
4653
4654void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004655 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004656 auto lock = cb_write_lock();
4657 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4658 if (item->second == commandPool) {
4659 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004660 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004661 ++item;
4662 }
4663 }
4664}
4665
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004666bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004667 const VkAllocationCallbacks *pAllocator,
4668 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004669 bool skip = false;
4670
4671 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004672 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004673 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004674 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4675 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004676 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004677
4678 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004679 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004680 if (flags_info) {
4681 flags = flags_info->flags;
4682 }
4683
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004684 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004685 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004686 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004687 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4688 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004689 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004690 }
4691
4692#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004693 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004694#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004695 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4696 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004697#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004698 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004699#endif
4700
4701 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004702 skip |= LogError(
4703 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004704 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4705 }
4706 if (
4707#ifdef VK_USE_PLATFORM_WIN32_KHR
4708 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4709#endif
4710 (import_memory_fd && import_memory_fd->handleType) ||
4711#ifdef VK_USE_PLATFORM_ANDROID_KHR
4712 (import_memory_ahb && import_memory_ahb->buffer) ||
4713#endif
4714 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004715 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4716 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004717 }
4718 }
4719
4720 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004721 VkBool32 capture_replay = false;
4722 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004723 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004724 if (vulkan_12_features) {
4725 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4726 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4727 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004728 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004729 if (bda_features) {
4730 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4731 buffer_device_address = bda_features->bufferDeviceAddress;
4732 }
4733 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004734 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004735 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004736 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004737 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004738 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004739 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004740 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004741 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004742 }
4743 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004744 }
4745 return skip;
4746}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004747
Jason Macnak192fa0e2019-07-26 15:07:16 -07004748bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004749 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004750 bool skip = false;
4751
4752 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4753 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4754 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004755 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004756 } else {
4757 uint32_t vertex_component_size = 0;
4758 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4759 vertex_component_size = 4;
4760 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4761 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4762 vertex_component_size = 2;
4763 }
4764 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004765 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004766 }
4767 }
4768
4769 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4770 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004771 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004772 } else {
4773 uint32_t index_element_size = 0;
4774 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4775 index_element_size = 4;
4776 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4777 index_element_size = 2;
4778 }
4779 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004780 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004781 }
4782 }
4783 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4784 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004785 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004786 }
4787 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004788 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004789 }
4790 }
4791
4792 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004793 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004794 }
4795
4796 return skip;
4797}
4798
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004799bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4800 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004801 bool skip = false;
4802
4803 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004804 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004805 }
4806 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004807 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004808 }
4809
4810 return skip;
4811}
4812
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004813bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4814 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004815 bool skip = false;
4816 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004817 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004818 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004819 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004820 }
4821 return skip;
4822}
4823
4824bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004825 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004826 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004827 bool skip = false;
4828 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004829 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4830 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4831 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004832 }
4833 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004834 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4835 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4836 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004837 }
4838 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4839 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004840 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4841 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4842 "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 -07004843 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004844 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004845 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004846 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4847 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004848 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4849 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004850 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004851 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004852 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4853 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4854 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004855 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004856 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004857 uint64_t total_triangle_count = 0;
4858 for (uint32_t i = 0; i < info.geometryCount; i++) {
4859 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004860
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004861 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004862
Jason Macnak5c954952019-07-09 15:46:12 -07004863 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4864 continue;
4865 }
4866 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4867 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004868 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004869 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4870 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4871 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004872 }
4873 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004874 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4875 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4876 for (uint32_t i = 1; i < info.geometryCount; i++) {
4877 const VkGeometryNV &geometry = info.pGeometries[i];
4878 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004879 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004880 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4881 "info.pGeometries[0].geometryType.",
4882 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004883 }
4884 }
4885 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004886 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4887 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4888 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4889 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4890 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4891 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4892 }
4893 }
4894 skip |=
4895 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004896 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004897 return skip;
4898}
4899
Ricardo Garciaa4935972019-02-21 17:43:18 +01004900bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4901 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004902 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004903 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004904 if (pCreateInfo) {
4905 if ((pCreateInfo->compactedSize != 0) &&
4906 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004907 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4908 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4909 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4910 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004911 }
Jason Macnak5c954952019-07-09 15:46:12 -07004912
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004913 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004914 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004915 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004916 return skip;
4917}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004918
Jeff Bolz5c801d12019-10-09 10:38:45 -05004919bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4920 const VkAccelerationStructureInfoNV *pInfo,
4921 VkBuffer instanceData, VkDeviceSize instanceOffset,
4922 VkBool32 update, VkAccelerationStructureNV dst,
4923 VkAccelerationStructureNV src, VkBuffer scratch,
4924 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004925 bool skip = false;
4926
4927 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004928 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004929 }
4930
4931 return skip;
4932}
4933
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004934bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4935 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4936 VkAccelerationStructureKHR *pAccelerationStructure) const {
4937 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004938 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004939 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004940 if (!acceleration_structure_features ||
4941 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
4942 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
4943 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
4944 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004945 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004946 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
4947 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004948 (acceleration_structure_features &&
4949 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07004950 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07004951 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
4952 "vkCreateAccelerationStructureKHR(): If createFlags includes "
4953 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
4954 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07004955 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004956 if (pCreateInfo->deviceAddress &&
4957 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
4958 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
4959 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
4960 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
4961 }
4962 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
4963 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
4964 "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset);
4965 }
sourav parmar83c31b12020-05-06 12:30:54 -07004966 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004967 return skip;
4968}
4969
Jason Macnak5c954952019-07-09 15:46:12 -07004970bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4971 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004972 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004973 bool skip = false;
4974 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004975 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4976 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004977 }
4978 return skip;
4979}
4980
sourav parmarcd5fb182020-07-17 12:58:44 -07004981bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
4982 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
4983 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4984 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004985 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004986 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
4987 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004988 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004989 }
4990 return skip;
4991}
4992
Peter Chen85366392019-05-14 15:20:11 -04004993bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4994 uint32_t createInfoCount,
4995 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4996 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004997 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004998 bool skip = false;
4999
5000 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005001 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005002 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005003 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005004 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5005 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5006 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5007 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005008 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005009
5010 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005011 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005012 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5013 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5014 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5015 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5016 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5017 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5018 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5019 }
5020 }
5021
sourav parmarf4a78252020-04-10 13:04:21 -07005022 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5023 skip |=
5024 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5025 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5026 }
5027 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5028 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5029 skip |=
5030 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5031 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5032 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5033 }
5034 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5035 if (pCreateInfos[i].basePipelineIndex != -1) {
5036 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5037 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5038 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5039 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5040 "and pCreateInfos->basePipelineIndex is not -1.");
5041 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005042 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005043 skip |=
5044 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5045 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5046 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5047 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5048 "that element.");
5049 }
sourav parmarf4a78252020-04-10 13:04:21 -07005050 }
5051 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005052 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005053 skip |=
5054 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5055 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5056 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5057 "commands pCreateInfos parameter.");
5058 }
5059 } else {
5060 if (pCreateInfos[i].basePipelineIndex != -1) {
5061 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5062 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5063 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5064 }
5065 }
5066 }
5067 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5068 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5069 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5070 }
5071 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5072 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5073 "vkCreateRayTracingPipelinesNV: flags must not include "
5074 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5075 }
5076 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5077 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5078 "vkCreateRayTracingPipelinesNV: flags must not include "
5079 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5080 }
5081 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5082 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5083 "vkCreateRayTracingPipelinesNV: flags must not include "
5084 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5085 }
5086 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5087 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5088 "vkCreateRayTracingPipelinesNV: flags must not include "
5089 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5090 }
5091 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5092 skip |= LogError(
5093 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5094 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5095 }
5096 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5097 skip |= LogError(
5098 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5099 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5100 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005101 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5102 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5103 "vkCreateRayTracingPipelinesNV: flags must not include "
5104 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5105 }
5106 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5107 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5108 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5109 }
Peter Chen85366392019-05-14 15:20:11 -04005110 }
5111
5112 return skip;
5113}
5114
sourav parmarcd5fb182020-07-17 12:58:44 -07005115bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5116 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5117 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005118 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005119 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005120 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5121 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5122 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005123 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005124 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005125 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5126 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5127 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5128 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5129 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5130 }
5131 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5132 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5133 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5134 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5135 }
5136 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005137 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005138 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5139 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005140 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5141 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5142 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005143 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5144 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5145 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005146 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005147 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005148 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5149 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5150 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5151 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005152 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005153 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5154 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5155 }
5156 }
sourav parmarf4a78252020-04-10 13:04:21 -07005157 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005158 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5159 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005160 }
5161 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005162 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005163 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005164 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5165 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005166 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005167 }
5168 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5169 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5170 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005171 }
5172 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5173 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5174 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5175 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5176 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5177 skip |= LogError(
5178 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005179 "vkCreateRayTracingPipelinesKHR: If flags includes "
5180 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005181 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5182 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5183 "must not be VK_SHADER_UNUSED_KHR");
5184 }
5185 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5186 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5187 skip |= LogError(
5188 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005189 "vkCreateRayTracingPipelinesKHR: If flags includes "
5190 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005191 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5192 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5193 "element must not be VK_SHADER_UNUSED_KHR");
5194 }
5195 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005196 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5197 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5198 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5199 skip |= LogError(
5200 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5201 "vkCreateRayTracingPipelinesKHR: If "
5202 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5203 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5204 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5205 }
5206 }
sourav parmarf4a78252020-04-10 13:04:21 -07005207 }
5208 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5209 if (pCreateInfos[i].basePipelineIndex != -1) {
5210 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5211 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005212 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005213 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5214 "and pCreateInfos->basePipelineIndex is not -1.");
5215 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005216 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005217 skip |=
5218 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5219 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5220 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5221 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5222 "element.");
5223 }
sourav parmarf4a78252020-04-10 13:04:21 -07005224 }
5225 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005226 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005227 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005228 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005229 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5230 "commands pCreateInfos parameter %d.",
5231 pCreateInfos[i].basePipelineIndex, createInfoCount);
5232 }
5233 } else {
5234 if (pCreateInfos[i].basePipelineIndex != -1) {
5235 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005236 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005237 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5238 }
5239 }
5240 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005241 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5242 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5243 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5244 "vkCreateRayTracingPipelinesKHR: If flags includes "
5245 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5246 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005247 }
5248 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5249 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5250 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5251 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5252 "pLibraryInfo and pLibraryInterface must be NULL.");
5253 }
5254 if (pCreateInfos[i].pLibraryInfo) {
5255 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5256 if (pCreateInfos[i].stageCount == 0) {
5257 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5258 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5259 "stageCount must not be 0.");
5260 }
5261 if (pCreateInfos[i].groupCount == 0) {
5262 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5263 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5264 "groupCount must not be 0.");
5265 }
5266 } else {
5267 if (pCreateInfos[i].pLibraryInterface == NULL) {
5268 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5269 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5270 "is greater than 0, its "
5271 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005272 }
5273 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005274 }
5275 if (pCreateInfos[i].pLibraryInterface) {
5276 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5277 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5278 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5279 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5280 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5281 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005282 }
5283 if (deferredOperation != VK_NULL_HANDLE) {
5284 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5285 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5286 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5287 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005288 }
5289 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005290 }
5291
5292 return skip;
5293}
5294
Mike Schuchardt21638df2019-03-16 10:52:02 -07005295#ifdef VK_USE_PLATFORM_WIN32_KHR
5296bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5297 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005298 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005299 bool skip = false;
5300 if (!device_extensions.vk_khr_swapchain)
5301 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
5302 if (!device_extensions.vk_khr_get_surface_capabilities_2)
5303 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5304 if (!device_extensions.vk_khr_surface)
5305 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
5306 if (!device_extensions.vk_khr_get_physical_device_properties_2)
5307 skip |=
5308 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5309 if (!device_extensions.vk_ext_full_screen_exclusive)
5310 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5311 skip |= validate_struct_type(
5312 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5313 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5314 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5315 if (pSurfaceInfo != NULL) {
5316 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5317 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5318 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5319
5320 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5321 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5322 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5323 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005324 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5325 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005326
5327 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5328 }
5329 return skip;
5330}
5331#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005332
5333bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5334 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005335 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005336 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5337 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005338 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005339 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5340 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5341 }
5342 return skip;
5343}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005344
5345bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005346 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005347 bool skip = false;
5348
5349 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005350 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5351 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005352 }
5353
5354 return skip;
5355}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005356
5357bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005358 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005359 bool skip = false;
5360
5361 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005362 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5363 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005364 }
5365
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005366 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005367 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005368 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5369 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005370 }
5371
5372 return skip;
5373}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005374
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005375bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5376 uint32_t bindingCount, const VkBuffer *pBuffers,
5377 const VkDeviceSize *pOffsets) const {
5378 bool skip = false;
5379 if (firstBinding > device_limits.maxVertexInputBindings) {
5380 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5381 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5382 device_limits.maxVertexInputBindings);
5383 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5384 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5385 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5386 "maxVertexInputBindings (%u)",
5387 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5388 }
5389
Jeff Bolz165818a2020-05-08 11:19:03 -05005390 for (uint32_t i = 0; i < bindingCount; ++i) {
5391 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005392 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005393 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5394 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5395 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5396 } else {
5397 if (pOffsets[i] != 0) {
5398 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5399 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5400 }
5401 }
5402 }
5403 }
5404
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005405 return skip;
5406}
5407
Mark Lobodzinski84988402019-09-11 15:27:30 -06005408bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005409 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005410 bool skip = false;
5411 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005412 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5413 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005414 }
5415 return skip;
5416}
5417
5418bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005419 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005420 bool skip = false;
5421 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005422 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5423 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005424 }
5425 return skip;
5426}
Petr Kraus3d720392019-11-13 02:52:39 +01005427
5428bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5429 VkSemaphore semaphore, VkFence fence,
5430 uint32_t *pImageIndex) const {
5431 bool skip = false;
5432
5433 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005434 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5435 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005436 }
5437
5438 return skip;
5439}
5440
5441bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5442 uint32_t *pImageIndex) const {
5443 bool skip = false;
5444
5445 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005446 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5447 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005448 }
5449
5450 return skip;
5451}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005452
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005453bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5454 uint32_t firstBinding, uint32_t bindingCount,
5455 const VkBuffer *pBuffers,
5456 const VkDeviceSize *pOffsets,
5457 const VkDeviceSize *pSizes) const {
5458 bool skip = false;
5459
5460 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5461 for (uint32_t i = 0; i < bindingCount; ++i) {
5462 if (pOffsets[i] & 3) {
5463 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5464 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5465 }
5466 }
5467
5468 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5469 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5470 "%s: The firstBinding(%" PRIu32
5471 ") index is greater than or equal to "
5472 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5473 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5474 }
5475
5476 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5477 skip |=
5478 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5479 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5480 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5481 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5482 }
5483
5484 for (uint32_t i = 0; i < bindingCount; ++i) {
5485 // pSizes is optional and may be nullptr.
5486 if (pSizes != nullptr) {
5487 if (pSizes[i] != VK_WHOLE_SIZE &&
5488 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5489 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5490 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5491 ") is not VK_WHOLE_SIZE and is greater than "
5492 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5493 cmd_name, i, pSizes[i]);
5494 }
5495 }
5496 }
5497
5498 return skip;
5499}
5500
5501bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5502 uint32_t firstCounterBuffer,
5503 uint32_t counterBufferCount,
5504 const VkBuffer *pCounterBuffers,
5505 const VkDeviceSize *pCounterBufferOffsets) const {
5506 bool skip = false;
5507
5508 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5509 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5510 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5511 "%s: The firstCounterBuffer(%" PRIu32
5512 ") index is greater than or equal to "
5513 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5514 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5515 }
5516
5517 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5518 skip |=
5519 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5520 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5521 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5522 cmd_name, firstCounterBuffer, counterBufferCount,
5523 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5524 }
5525
5526 return skip;
5527}
5528
5529bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5530 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5531 const VkBuffer *pCounterBuffers,
5532 const VkDeviceSize *pCounterBufferOffsets) const {
5533 bool skip = false;
5534
5535 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5536 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5537 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5538 "%s: The firstCounterBuffer(%" PRIu32
5539 ") index is greater than or equal to "
5540 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5541 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5542 }
5543
5544 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5545 skip |=
5546 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5547 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5548 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5549 cmd_name, firstCounterBuffer, counterBufferCount,
5550 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5551 }
5552
5553 return skip;
5554}
5555
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005556bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5557 uint32_t firstInstance, VkBuffer counterBuffer,
5558 VkDeviceSize counterBufferOffset,
5559 uint32_t counterOffset, uint32_t vertexStride) const {
5560 bool skip = false;
5561
5562 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005563 skip |= LogError(
5564 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005565 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5566 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5567 }
5568
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005569 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005570 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005571 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5572 }
5573
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005574 return skip;
5575}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005576
5577bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5578 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5579 const VkAllocationCallbacks *pAllocator,
5580 VkSamplerYcbcrConversion *pYcbcrConversion,
5581 const char *apiName) const {
5582 bool skip = false;
5583
5584 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005585 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005586 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005587 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005588 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5589 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005590 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005591 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005592 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005593
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005594#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005595 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005596 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005597#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005598 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005599#endif
5600
sfricke-samsung1a72f942020-07-25 12:09:18 -07005601 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005602
5603 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005604 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005605 const VkComponentMapping components = pCreateInfo->components;
5606 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5607 if (FormatIsXChromaSubsampled(format) == true) {
5608 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5609 skip |=
5610 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005611 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5612 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005613 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005614 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005615
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005616 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5617 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5618 skip |= LogError(
5619 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5620 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5621 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5622 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5623 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005624
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005625 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5626 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5627 skip |=
5628 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005629 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5630 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005631 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005632 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005633
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005634 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5635 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5636 skip |=
5637 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005638 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5639 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005640 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005641 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005642
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005643 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005644 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5645 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5646 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005647 skip |=
5648 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005649 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5650 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005651 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5652 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005653 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005654 }
5655
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005656 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5657 // Checks same VU multiple ways in order to give a more useful error message
5658 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5659 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5660 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5661 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5662 skip |= LogError(
5663 device, vuid,
5664 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5665 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5666 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5667 string_VkComponentSwizzle(components.b));
5668 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005669
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005670 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5671 // 4 channel format = no issue
5672 // 3 = no [a]
5673 // 2 = no [b,a]
5674 // 1 = no [g,b,a]
5675 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5676 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5677
5678 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5679 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5680 skip |= LogError(device, vuid,
5681 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5682 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5683 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5684 string_VkComponentSwizzle(components.b));
5685 } else if ((channels < 3) &&
5686 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5687 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5688 skip |= LogError(device, vuid,
5689 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5690 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5691 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5692 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5693 string_VkComponentSwizzle(components.b));
5694 } else if ((channels < 2) &&
5695 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5696 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5697 skip |= LogError(device, vuid,
5698 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5699 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5700 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5701 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5702 string_VkComponentSwizzle(components.b));
5703 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005704 }
5705 }
5706
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005707 return skip;
5708}
5709
5710bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5711 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5712 const VkAllocationCallbacks *pAllocator,
5713 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5714 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5715 "vkCreateSamplerYcbcrConversion");
5716}
5717
5718bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5719 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5720 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5721 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5722 "vkCreateSamplerYcbcrConversionKHR");
5723}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005724
5725bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5726 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5727 bool skip = false;
5728 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5729 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5730
5731 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005732 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5733 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5734 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5735 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5736 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005737 }
5738 return skip;
5739}
sourav parmara96ab1a2020-04-25 16:28:23 -07005740
5741bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005742 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005743 bool skip = false;
5744 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5745 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5746 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5747 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005748 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005749 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5750 skip |= LogError(
5751 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5752 "vkCopyAccelerationStructureToMemoryKHR: The "
5753 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5754 }
5755 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5756 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5757 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5758 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5759 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5760 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005761 return skip;
5762}
5763
5764bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5765 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5766 bool skip = false;
5767 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5768 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5769 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5770 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5771 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005772 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5773 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
5774 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.",
5775 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005776 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005777 return skip;
5778}
5779
5780bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5781 const char *api_name) const {
5782 bool skip = false;
5783 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5784 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5785 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5786 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5787 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5788 api_name);
5789 }
5790 return skip;
5791}
5792
5793bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005794 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005795 bool skip = false;
5796 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005797 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005798 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005799 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005800 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5801 "vkCopyAccelerationStructureKHR: The "
5802 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005803 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005804 return skip;
5805}
5806
5807bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5808 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5809 bool skip = false;
5810 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5811 return skip;
5812}
5813
5814bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005815 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005816 bool skip = false;
5817 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005818 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005819 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5820 }
5821 return skip;
5822}
5823
5824bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005825 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005826 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005827 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005828 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005829 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5830 skip |= LogError(
5831 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5832 "vkCopyMemoryToAccelerationStructureKHR: The "
5833 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005834 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005835 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
5836 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07005837 return skip;
5838}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005839
sourav parmara96ab1a2020-04-25 16:28:23 -07005840bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5841 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5842 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005843 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07005844 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
5845 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
5846 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.",
5847 pInfo->src.deviceAddress);
5848 }
sourav parmar83c31b12020-05-06 12:30:54 -07005849 return skip;
5850}
5851bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5852 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5853 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5854 bool skip = false;
5855 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5856 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5857 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5858 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5859 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5860 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5861 }
5862 return skip;
5863}
5864bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5865 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5866 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5867 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005868 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005869 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
5870 skip |= LogError(
5871 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
5872 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
5873 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5874 }
sourav parmar83c31b12020-05-06 12:30:54 -07005875 if (dataSize < accelerationStructureCount * stride) {
5876 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5877 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5878 "accelerationStructureCount (%d) *stride(%zu).",
5879 dataSize, accelerationStructureCount, stride);
5880 }
5881 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5882 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5883 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5884 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5885 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5886 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5887 }
5888 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5889 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5890 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5891 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5892 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5893 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5894 stride);
5895 }
5896 }
5897 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5898 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5899 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5900 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5901 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5902 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5903 stride);
5904 }
5905 }
sourav parmar83c31b12020-05-06 12:30:54 -07005906 return skip;
5907}
5908bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5909 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5910 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005911 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005912 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
5913 skip |= LogError(
5914 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
5915 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
5916 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07005917 }
5918 return skip;
5919}
5920
5921bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07005922 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5923 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
5924 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5925 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07005926 uint32_t width, uint32_t height, uint32_t depth) const {
5927 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005928 // RayGen
5929 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5930 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
5931 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005932 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005933 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5934 0) {
5935 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
5936 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5937 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5938 }
5939 // Callable
5940 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5941 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
5942 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5943 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005944 }
5945 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5946 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5947 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005948 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5949 }
5950 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5951 0) {
5952 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
5953 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5954 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005955 }
5956 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005957 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5958 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
5959 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5960 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005961 }
5962 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5963 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005964 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
5965 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07005966 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005967 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5968 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
5969 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5970 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5971 }
sourav parmar83c31b12020-05-06 12:30:54 -07005972 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005973 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5974 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
5975 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
5976 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07005977 }
5978 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5979 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5980 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005981 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5982 }
5983 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5984 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
5985 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5986 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5987 }
5988 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
5989 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
5990 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
5991 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
5992 }
5993 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
5994 skip |=
5995 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
5996 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
5997 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07005998 }
5999
sourav parmarcd5fb182020-07-17 12:58:44 -07006000 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6001 skip |=
6002 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6003 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6004 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6005 }
6006
6007 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6008 skip |=
6009 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6010 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6011 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006012 }
6013 return skip;
6014}
6015
sourav parmarcd5fb182020-07-17 12:58:44 -07006016bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6017 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6018 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6019 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006020 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006021 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006022 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6023 skip |= LogError(
6024 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6025 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6026 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006027 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006028 // RayGen
6029 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6030 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6031 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006032 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006033 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6034 0) {
6035 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6036 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6037 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6038 }
6039 // Callabe
6040 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6041 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6042 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6043 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006044 }
6045 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6046 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006047 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6048 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6049 }
6050 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6051 0) {
6052 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6053 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6054 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006055 }
6056 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006057 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6058 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6059 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6060 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006061 }
6062 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6063 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006064 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6065 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006066 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006067 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6068 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6069 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6070 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6071 }
sourav parmar83c31b12020-05-06 12:30:54 -07006072 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006073 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6074 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6075 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6076 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006077 }
6078 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6079 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006080 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6081 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6082 }
6083 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6084 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6085 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6086 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006087 }
6088
sourav parmarcd5fb182020-07-17 12:58:44 -07006089 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6090 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6091 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006092 }
6093 return skip;
6094}
6095bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6096 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6097 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6098 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6099 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6100 uint32_t width, uint32_t height, uint32_t depth) const {
6101 bool skip = false;
6102 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6103 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6104 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6105 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6106 }
6107 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6108 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6109 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6110 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6111 }
6112 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6113 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6114 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6115 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6116 }
6117
6118 // hitShader
6119 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6120 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6121 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6122 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6123 }
6124 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6125 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6126 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6127 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6128 }
6129 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6130 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6131 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6132 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6133 }
6134
6135 // missShader
6136 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6137 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6138 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6139 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6140 }
6141 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6142 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6143 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6144 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6145 }
6146 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6147 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6148 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6149 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6150 }
6151
6152 // raygenShader
6153 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6154 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6155 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006156 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6157 }
6158 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6159 skip |=
6160 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6161 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6162 }
6163 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6164 skip |=
6165 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6166 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6167 }
6168 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6169 skip |=
6170 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6171 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006172 }
6173 return skip;
6174}
6175
sourav parmar83c31b12020-05-06 12:30:54 -07006176bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006177 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6178 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006179 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006180 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6181 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006182 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6183 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006184 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006185 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6186 }
6187 return skip;
6188}
6189
Piers Daniell39842ee2020-07-10 16:42:33 -06006190bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6191 const VkViewport *pViewports) const {
6192 bool skip = false;
6193
6194 if (!physical_device_features.multiViewport) {
6195 if (viewportCount != 1) {
6196 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6197 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6198 ") is not 1.",
6199 viewportCount);
6200 }
6201 } else { // multiViewport enabled
6202 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6203 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6204 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6205 ") must "
6206 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6207 viewportCount, device_limits.maxViewports);
6208 }
6209 }
6210
6211 if (pViewports) {
6212 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6213 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6214 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6215 skip |= manual_PreCallValidateViewport(
6216 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6217 }
6218 }
6219
6220 return skip;
6221}
6222
6223bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6224 const VkRect2D *pScissors) const {
6225 bool skip = false;
6226
6227 if (!physical_device_features.multiViewport) {
6228 if (scissorCount != 1) {
6229 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6230 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6231 ") must "
6232 "be 1 when the multiViewport feature is disabled.",
6233 scissorCount);
6234 }
6235 } else { // multiViewport enabled
6236 if (scissorCount == 0) {
6237 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6238 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6239 ") must "
6240 "be great than zero.",
6241 scissorCount);
6242 } else if (scissorCount > device_limits.maxViewports) {
6243 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6244 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6245 ") must "
6246 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6247 scissorCount, device_limits.maxViewports);
6248 }
6249 }
6250
6251 if (pScissors) {
6252 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6253 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6254
6255 if (scissor.offset.x < 0) {
6256 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6257 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6258 scissor.offset.x);
6259 }
6260
6261 if (scissor.offset.y < 0) {
6262 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6263 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6264 scissor.offset.y);
6265 }
6266
6267 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6268 if (x_sum > INT32_MAX) {
6269 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6270 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6271 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6272 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6273 }
6274
6275 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6276 if (y_sum > INT32_MAX) {
6277 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6278 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6279 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6280 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6281 }
6282 }
6283 }
6284
6285 return skip;
6286}
6287
6288bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6289 uint32_t bindingCount, const VkBuffer *pBuffers,
6290 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6291 const VkDeviceSize *pStrides) const {
6292 bool skip = false;
6293 if (firstBinding >= device_limits.maxVertexInputBindings) {
6294 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6295 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6296 firstBinding, device_limits.maxVertexInputBindings);
6297 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6298 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6299 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6300 "maxVertexInputBindings (%u)",
6301 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6302 }
6303
6304 for (uint32_t i = 0; i < bindingCount; ++i) {
6305 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006306 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006307 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6308 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6309 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6310 } else {
6311 if (pOffsets[i] != 0) {
6312 skip |=
6313 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6314 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6315 }
6316 }
6317 }
6318 if (pStrides) {
6319 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6320 skip |=
6321 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
6322 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
6323 pStrides[i], device_limits.maxVertexInputBindingStride);
6324 }
6325 }
6326 }
6327
6328 return skip;
6329}
sourav parmarcd5fb182020-07-17 12:58:44 -07006330
6331bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6332 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6333 bool skip = false;
6334 for (uint32_t i = 0; i < infoCount; ++i) {
6335 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6336 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6337 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6338 }
6339 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6340 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6341 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6342 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6343 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6344 api_name);
6345 }
6346 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6347 skip |=
6348 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6349 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6350 }
6351 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6352 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6353 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6354 }
6355 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6356 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6357 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6358 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6359 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6360 api_name);
6361 }
6362 if (pInfos[i].pGeometries) {
6363 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6364 skip |= validate_ranged_enum(
6365 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6366 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6367 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6368 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006369 skip |= validate_struct_type(
6370 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6371 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6372 &(pInfos[i].pGeometries[j].geometry.triangles),
6373 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6374 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6375 skip |= validate_struct_pnext(
6376 api_name,
6377 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6378 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6379 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6380 skip |=
6381 validate_ranged_enum(api_name,
6382 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6383 ParameterName::IndexVector{i, j}),
6384 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6385 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6386 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6387 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6388 &pInfos[i].pGeometries[j].geometry.triangles,
6389 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6390 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6391 skip |= validate_ranged_enum(
6392 api_name,
6393 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6394 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6395 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6396
6397 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6398 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6399 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6400 }
6401 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6402 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6403 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6404 skip |=
6405 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6406 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6407 api_name);
6408 }
6409 }
6410 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6411 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6412 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6413 &pInfos[i].pGeometries[j].geometry.instances,
6414 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6415 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6416 skip |= validate_struct_type(
6417 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6418 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6419 &(pInfos[i].pGeometries[j].geometry.instances),
6420 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6421 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6422 skip |= validate_struct_pnext(
6423 api_name,
6424 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6425 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6426 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6427
6428 skip |= validate_bool32(api_name,
6429 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6430 ParameterName::IndexVector{i, j}),
6431 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6432 }
6433 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6434 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6435 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6436 &pInfos[i].pGeometries[j].geometry.aabbs,
6437 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6438 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6439 skip |= validate_struct_type(
6440 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6441 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6442 &(pInfos[i].pGeometries[j].geometry.aabbs),
6443 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6444 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6445 skip |= validate_struct_pnext(
6446 api_name,
6447 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6448 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6449 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6450 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6451 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6452 "(%s):stride must be less than or equal to 2^32-1", api_name);
6453 }
6454 }
6455 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6456 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6457 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6458 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6459 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6460 api_name);
6461 }
6462 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6463 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6464 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6465 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6466 "of elements of"
6467 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6468 api_name);
6469 }
6470 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6471 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6472 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6473 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6474 api_name);
6475 }
6476 }
6477 }
6478 }
6479 if (pInfos[i].ppGeometries != NULL) {
6480 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6481 skip |= validate_ranged_enum(
6482 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6483 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6484 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6485 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006486 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6487 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6488 &pInfos[i].ppGeometries[j]->geometry.triangles,
6489 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6490 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6491 skip |= validate_struct_type(
6492 api_name,
6493 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6494 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6495 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6496 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6497 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6498 skip |= validate_struct_pnext(
6499 api_name,
6500 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6501 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6502 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6503 skip |= validate_ranged_enum(api_name,
6504 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6505 ParameterName::IndexVector{i, j}),
6506 "VkFormat", AllVkFormatEnums,
6507 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6508 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6509 skip |= validate_ranged_enum(api_name,
6510 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6511 ParameterName::IndexVector{i, j}),
6512 "VkIndexType", AllVkIndexTypeEnums,
6513 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6514 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6515 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6516 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6517 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6518 }
6519 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6520 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6521 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6522 skip |=
6523 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6524 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6525 api_name);
6526 }
6527 }
6528 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6529 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6530 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6531 &pInfos[i].ppGeometries[j]->geometry.instances,
6532 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6533 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6534 skip |= validate_struct_type(
6535 api_name,
6536 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6537 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6538 &(pInfos[i].ppGeometries[j]->geometry.instances),
6539 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6540 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6541 skip |= validate_struct_pnext(
6542 api_name,
6543 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6544 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6545 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6546 skip |= validate_bool32(api_name,
6547 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6548 ParameterName::IndexVector{i, j}),
6549 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6550 }
6551 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6552 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6553 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6554 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6555 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6556 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6557 skip |= validate_struct_type(
6558 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6559 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6560 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6561 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6562 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6563 skip |= validate_struct_pnext(
6564 api_name,
6565 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6566 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6567 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6568 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6569 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6570 "(%s):stride must be less than or equal to 2^32-1", api_name);
6571 }
6572 }
6573 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6574 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6575 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6576 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6577 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6578 api_name);
6579 }
6580 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6581 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6582 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6583 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6584 "of elements of"
6585 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6586 api_name);
6587 }
6588 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6589 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6590 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6591 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6592 api_name);
6593 }
6594 }
6595 }
6596 }
6597 }
6598 return skip;
6599}
6600bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6601 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6602 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6603 bool skip = false;
6604 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6605 for (uint32_t i = 0; i < infoCount; ++i) {
6606 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6607 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6608 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6609 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6610 "scratchData.deviceAddress member must be a multiple of "
6611 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6612 }
6613 for (uint32_t k = 0; k < infoCount; ++k) {
6614 if (i == k) continue;
6615 bool found = false;
6616 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6617 skip |= LogError(
6618 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6619 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6620 "not be "
6621 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6622 i, k);
6623 found = true;
6624 }
6625 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6626 skip |= LogError(
6627 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6628 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6629 "not be "
6630 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6631 i, k);
6632 found = true;
6633 }
6634 if (found) break;
6635 }
6636 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6637 if (pInfos[i].pGeometries) {
6638 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6639 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6640 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6641 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6642 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6643 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6644 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6645 }
6646 } else {
6647 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6648 skip |=
6649 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6650 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6651 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6652 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6653 }
6654 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006655 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006656 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6657 skip |= LogError(
6658 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6659 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6660 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6661 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006662 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6663 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006664 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6665 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6666 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6667 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6668 }
6669 }
6670 } else if (pInfos[i].ppGeometries) {
6671 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6672 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6673 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6674 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6675 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6676 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6677 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6678 }
6679 } else {
6680 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6681 skip |=
6682 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6683 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6684 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6685 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6686 }
6687 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006688 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006689 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6690 skip |= LogError(
6691 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6692 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6693 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6694 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006695 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6696 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006697 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6698 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6699 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6700 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6701 }
6702 }
6703 }
6704 }
6705 }
6706 return skip;
6707}
6708
6709bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6710 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6711 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6712 const uint32_t *const *ppMaxPrimitiveCounts) const {
6713 bool skip = false;
6714 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6715 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006716 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006717 if (!ray_tracing_acceleration_structure_features ||
6718 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6719 skip |= LogError(
6720 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6721 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6722 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6723 }
6724 for (uint32_t i = 0; i < infoCount; ++i) {
6725 if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) {
6726 if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) {
6727 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666",
6728 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is "
6729 "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be "
6730 "VK_NULL_HANDLE.");
6731 }
6732 }
6733 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6734 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6735 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6736 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6737 "scratchData.deviceAddress member must be a multiple of "
6738 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6739 }
6740 for (uint32_t k = 0; k < infoCount; ++k) {
6741 if (i == k) continue;
6742 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6743 skip |=
6744 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6745 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6746 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6747 "any other element [%d) of pInfos.",
6748 i, k);
6749 break;
6750 }
6751 }
6752 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6753 if (pInfos[i].pGeometries) {
6754 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6755 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6756 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6757 skip |= LogError(
6758 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6759 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6760 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6761 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6762 }
6763 } else {
6764 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6765 skip |= LogError(
6766 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6767 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6768 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6769 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6770 }
6771 }
6772 }
6773 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6774 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6775 skip |= LogError(
6776 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6777 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6778 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6779 }
6780 }
6781 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6782 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6783 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6784 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6785 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6786 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6787 }
6788 }
6789 } else if (pInfos[i].ppGeometries) {
6790 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6791 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6792 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6793 skip |= LogError(
6794 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6795 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6796 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6797 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6798 }
6799 } else {
6800 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6801 skip |= LogError(
6802 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6803 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6804 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6805 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6806 }
6807 }
6808 }
6809 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6810 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6811 skip |= LogError(
6812 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6813 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6814 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6815 }
6816 }
6817 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6818 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6819 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6820 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6821 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6822 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6823 }
6824 }
6825 }
6826 }
6827 }
6828 return skip;
6829}
6830
6831bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6832 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6833 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6834 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6835 bool skip = false;
6836 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6837 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006838 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006839 if (!ray_tracing_acceleration_structure_features ||
6840 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6841 skip |=
6842 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
6843 "vkBuildAccelerationStructuresKHR: The "
6844 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
6845 }
6846 for (uint32_t i = 0; i < infoCount; ++i) {
6847 for (uint32_t j = 0; j < infoCount; ++j) {
6848 if (i == j) continue;
6849 bool found = false;
6850 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6851 skip |= LogError(
6852 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6853 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
6854 "not be "
6855 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6856 i, j);
6857 found = true;
6858 }
6859 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6860 skip |= LogError(
6861 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
6862 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
6863 "not be "
6864 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6865 i, j);
6866 found = true;
6867 }
6868 if (found) break;
6869 }
6870 }
6871 return skip;
6872}
6873
6874bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
6875 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
6876 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
6877 bool skip = false;
6878 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
6879 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006880 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
6881 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006882 if (!(ray_tracing_pipeline_features || ray_query_features) ||
6883 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
6884 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
6885 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
6886 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
6887 }
6888 return skip;
6889}
sfricke-samsungecafb192021-01-17 08:21:14 -08006890
6891bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
6892 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
6893 const VkAllocationCallbacks *pAllocator,
6894 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
6895 bool skip = false;
6896 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
6897 if (private_data_features && private_data_features->privateData == VK_FALSE) {
6898 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
6899 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
6900 }
6901 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07006902}
Piers Daniellcb6d8032021-04-19 18:51:26 -06006903
6904bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
6905 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
6906 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
6907 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
6908 bool skip = false;
6909 const auto *vertex_input_dynamic_state_features =
6910 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
6911 const auto *vertex_attribute_divisor_features =
6912 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
6913
6914 // VUID-vkCmdSetVertexInputEXT-None-04790
6915 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
6916 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
6917 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
6918 }
6919
6920 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
6921 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
6922 skip |=
6923 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
6924 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
6925 }
6926
6927 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
6928 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
6929 skip |= LogError(
6930 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
6931 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
6932 }
6933
6934 // VUID-vkCmdSetVertexInputEXT-binding-04793
6935 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
6936 bool binding_found = false;
6937 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
6938 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
6939 binding_found = true;
6940 break;
6941 }
6942 }
6943 if (!binding_found) {
6944 skip |=
6945 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
6946 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
6947 }
6948 }
6949
6950 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
6951 if (vertexBindingDescriptionCount > 1) {
6952 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
6953 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
6954 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
6955 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
6956 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
6957 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
6958 }
6959 }
6960 }
6961 }
6962
6963 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
6964 if (vertexAttributeDescriptionCount > 1) {
6965 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
6966 uint32_t location = pVertexAttributeDescriptions[attribute].location;
6967 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
6968 if (location == pVertexAttributeDescriptions[next_attribute].location) {
6969 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
6970 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
6971 }
6972 }
6973 }
6974 }
6975
6976 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
6977 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
6978 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
6979 skip |= LogError(
6980 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
6981 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
6982 }
6983
6984 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
6985 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
6986 skip |= LogError(
6987 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
6988 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
6989 binding);
6990 }
6991
6992 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
6993 if (pVertexBindingDescriptions[binding].divisor == 0 &&
6994 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
6995 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
6996 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
6997 "vertexAttributeInstanceRateZeroDivisor is not enabled",
6998 binding);
6999 }
7000
7001 if (pVertexBindingDescriptions[binding].divisor > 1) {
7002 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7003 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7004 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7005 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7006 "vertexAttributeInstanceRateDivisor is not enabled",
7007 binding);
7008 } else {
7009 // VUID-VkVertexInputBindingDescription2EXT-divisor-04800
7010 if (pVertexBindingDescriptions[binding].divisor >
7011 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7012 skip |= LogError(
7013 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04800",
7014 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7015 binding);
7016 }
7017
7018 // VUID-VkVertexInputBindingDescription2EXT-divisor-04801
7019 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7020 skip |=
7021 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04801",
7022 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7023 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7024 binding);
7025 }
7026 }
7027 }
7028 }
7029
7030 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7031 // VUID-VkVertexInputAttributeDescription2EXT-location-04802
7032 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7033 skip |= LogError(
7034 device, "VUID-VkVertexInputAttributeDescription2EXT-location-04802",
7035 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7036 attribute);
7037 }
7038
7039 // VUID-VkVertexInputAttributeDescription2EXT-binding-04803
7040 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7041 skip |= LogError(
7042 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-04803",
7043 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7044 attribute);
7045 }
7046
7047 // VUID-VkVertexInputAttributeDescription2EXT-offset-04804
7048 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7049 skip |= LogError(
7050 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-04804",
7051 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7052 attribute);
7053 }
7054
7055 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7056 VkFormatProperties properties;
7057 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7058 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7059 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7060 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7061 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7062 attribute);
7063 }
7064 }
7065
7066 return skip;
7067}