blob: 0bcc00b077c8f68dad16c7208dec220dd356d208 [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) {
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700528 layer_data::unordered_set<uint32_t> set;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600529
530 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700531 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
532 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600533 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700534 skip |=
535 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
536 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
537 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
538 "index value.",
539 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600540 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700541 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
542 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
543 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
544 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600545 } else {
546 set.insert(requested_queue_family);
547 }
548
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700549 if (queue_create_info.pQueuePriorities != nullptr) {
550 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
551 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600552 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700553 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
554 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
555 "] (=%f) is not between 0 and 1 (inclusive).",
556 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600557 }
558 }
559 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700560
561 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700562 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700563 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700564 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700565 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700566 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700567 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700568 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700569 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700570 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700571 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
572 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
573 "protectedMemory feature being set as well.");
574 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600575 }
576 }
577
sfricke-samsung30a57412020-05-15 21:14:54 -0700578 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700579 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700580 VkBool32 variable_pointers = VK_FALSE;
581 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700582 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700583 variable_pointers = vulkan_11_features->variablePointers;
584 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700585 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700586 variable_pointers = variable_pointers_features->variablePointers;
587 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700588 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700589 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700590 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
591 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
592 }
593
sfricke-samsungfd76c342020-05-29 23:13:43 -0700594 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700595 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700596 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700597 VkBool32 multiview_geometry_shader = VK_FALSE;
598 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700599 if (vulkan_11_features) {
600 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700601 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
602 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700603 } else if (multiview_features) {
604 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700605 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
606 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700607 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700608 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700609 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
610 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
611 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700612 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700613 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
614 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
615 }
616
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600617 return skip;
618}
619
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500620bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700621 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700622 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
623 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
624 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600625 }
626
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700627 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600628}
629
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700630bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500631 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100632 bool skip = false;
633
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600634 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700635 skip |=
636 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600637
638 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
639 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
640 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
641 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700642 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
643 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
644 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600645 }
646
647 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
648 // queueFamilyIndexCount uint32_t values
649 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700650 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
651 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
652 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
653 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600654 }
655 }
656
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700657 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
658 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
659 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
660 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
661 }
662
663 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
664 skip |=
665 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
666 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
667 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
668 }
669
670 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
671 skip |=
672 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
673 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
674 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
675 }
676
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600677 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
678 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
679 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
680 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700681 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
682 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
683 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600684 }
685 }
686
687 return skip;
688}
689
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700690bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500691 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600692 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600693
694 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800695 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700696 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600697 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
698 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
699 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
700 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
702 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
703 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600704 }
705
706 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
707 // queueFamilyIndexCount uint32_t values
708 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
710 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
711 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
712 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600713 }
714 }
715
Dave Houlton413a6782018-05-22 13:01:54 -0600716 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700717 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600718 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700719 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600720 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700721 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600722
Dave Houlton413a6782018-05-22 13:01:54 -0600723 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700724 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600725 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600727
Dave Houlton130c0212018-01-29 13:39:56 -0700728 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700729 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
730 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700731 skip |= LogError(
732 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600733 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
734 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700735 }
736
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600737 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100738 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
739 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
741 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
742 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600743 }
744
745 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700746 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100747 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
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->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
751 ") are not equal.",
752 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100753 }
754
755 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700756 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
757 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
758 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
759 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100760 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600761 }
762
763 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700764 skip |= LogError(
765 device, "VUID-VkImageCreateInfo-imageType-00957",
766 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600767 }
768 }
769
Dave Houlton130c0212018-01-29 13:39:56 -0700770 // 3D image may have only 1 layer
771 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700772 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
773 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700774 }
775
Dave Houlton130c0212018-01-29 13:39:56 -0700776 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
777 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
778 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
779 // At least one of the legal attachment bits must be set
780 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
782 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700783 }
784 // No flags other than the legal attachment bits may be set
785 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
786 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700787 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
788 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700789 }
790 }
791
Jeff Bolzef40fec2018-09-01 22:04:34 -0500792 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700793 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500794 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700795 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700796 ? static_cast<uint32_t>(ceil(log2(max_dim)))
797 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
798 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600799 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700800 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
801 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
802 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600803 }
804
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700805 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700806 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
807 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
808 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600809 }
810
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700811 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700812 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
813 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
814 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100815 }
816
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700817 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700818 skip |= LogError(
819 device, "VUID-VkImageCreateInfo-flags-01924",
820 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
821 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
822 }
823
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600824 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
825 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700826 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
827 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700828 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
829 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
830 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600831 }
832
833 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700834 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600835 // Linear tiling is unsupported
836 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700837 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700838 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
839 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600840 }
841
842 // Sparse 1D image isn't valid
843 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700844 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
845 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600846 }
847
848 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700849 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700850 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
851 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
852 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600853 }
854
855 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700856 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700857 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
858 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
859 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600860 }
861
862 // Multi-sample 2D image when device doesn't support it
863 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700864 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600865 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700866 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
867 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
868 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700869 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600870 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700871 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
872 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
873 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700874 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600875 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700876 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
877 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
878 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700879 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600880 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700881 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
882 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
883 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600884 }
885 }
886 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500887
Jeff Bolz9af91c52018-09-01 21:53:57 -0500888 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
889 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700890 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
891 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
892 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500893 }
894 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700895 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
896 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
897 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500898 }
899 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700900 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
901 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
902 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500903 }
904 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500905
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700906 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600907 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700908 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
909 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
910 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500911 }
912
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700913 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700914 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
915 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800916 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
917 "depth/stencil format.",
918 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500919 }
920
Dave Houlton142c4cb2018-10-17 15:04:41 -0600921 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700922 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
923 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
924 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
925 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500926 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600927 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700928 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
929 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
930 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
931 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500932 }
933 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500934
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700935 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800936 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700937 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
938 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800939 "format (%s) must be a depth or depth/stencil format.",
940 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700941 }
942
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700943 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500944 if (image_stencil_struct != nullptr) {
945 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
946 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
947 // No flags other than the legal attachment bits may be set
948 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
949 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700950 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
951 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
952 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
953 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500954 }
955 }
956
sfricke-samsung61a57c02021-01-10 21:35:12 -0800957 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500958 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
959 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800960 skip |= LogError(
961 device, "VUID-VkImageCreateInfo-Format-02536",
962 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
963 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
964 "maxFramebufferWidth (%u)",
965 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500966 }
967
968 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800969 skip |= LogError(
970 device, "VUID-VkImageCreateInfo-format-02537",
971 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
972 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
973 "maxFramebufferHeight (%u)",
974 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500975 }
976 }
977
978 if (!physical_device_features.shaderStorageImageMultisample &&
979 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
980 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
981 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700982 LogError(device, "VUID-VkImageCreateInfo-format-02538",
983 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
984 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
985 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500986 }
987
988 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
989 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700990 skip |= LogError(
991 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500992 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
993 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
994 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
995 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
996 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700997 skip |= LogError(
998 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500999 "vkCreateImage(): Depth-stencil image in which usage does not include "
1000 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1001 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1002 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1003 }
1004
1005 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1006 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001007 skip |= LogError(
1008 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001009 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1010 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1011 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1012 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1013 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001014 skip |= LogError(
1015 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001016 "vkCreateImage(): Depth-stencil image in which usage does not include "
1017 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1018 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1019 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1020 }
1021 }
1022 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001023
1024 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1025 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1026 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1027 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1028 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1029 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001030
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001031 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001032 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001033 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1034 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001035 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1036 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1037 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1038 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1039 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1040 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1041 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001042 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001043 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1044 } else if (drm_format_mod_list != nullptr) {
1045 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1046 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1047 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001048 }
1049 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1050 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1051 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1052 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1053 "in the pNext chain");
1054 }
1055 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001056
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001057 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001058 bool image_create_maybe_linear = false;
1059 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1060 image_create_maybe_linear = true;
1061 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1062 image_create_maybe_linear = false;
1063 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1064 image_create_maybe_linear =
1065 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001066 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001067 }
1068
1069 // If multi-sample, validate type, usage, tiling and mip levels.
1070 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001071 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001072 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1073 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1074 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1075 }
1076
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001077 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001078 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1079 image_create_maybe_linear)) {
1080 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1081 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1082 }
1083
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001084 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1085 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1086 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1087 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1088 "imageType must be VK_IMAGE_TYPE_2D.");
1089 }
1090 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1091 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1092 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1093 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1094 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001095 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001096 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001097 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1098 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1099 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1100 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1101 }
1102 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1103 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1104 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1105 "imageType must be VK_IMAGE_TYPE_2D.");
1106 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001107 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001108 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1109 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1110 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1111 }
1112 if (pCreateInfo->mipLevels != 1) {
1113 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1114 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1115 pCreateInfo->mipLevels);
1116 }
1117 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001118
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001119 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001120 if (swapchain_create_info != nullptr) {
1121 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1122 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1123 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1124 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1125 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1126 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1127
1128 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1129 // also implicitly forces the check above that extent.depth is 1
1130 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1131 string_VkImageType(pCreateInfo->imageType));
1132 }
1133 if (pCreateInfo->mipLevels != 1) {
1134 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1135 pCreateInfo->mipLevels);
1136 }
1137 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1138 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1139 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1140 }
1141 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1142 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1143 base_message, string_VkImageTiling(pCreateInfo->tiling));
1144 }
1145 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1146 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1147 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1148 }
1149 const VkImageCreateFlags valid_flags =
1150 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001151 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001152 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001153 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001154 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001155 }
1156 }
1157 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001158
1159 // If Chroma subsampled format ( _420_ or _422_ )
1160 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1161 skip |=
1162 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1163 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1164 ") must be a multiple of 2.",
1165 string_VkFormat(image_format), pCreateInfo->extent.width);
1166 }
1167 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1168 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1169 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1170 ") must be a multiple of 2.",
1171 string_VkFormat(image_format), pCreateInfo->extent.height);
1172 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001173
1174 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1175 if (format_list_info) {
1176 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1177 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1178 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1179 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1180 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1181 viewFormatCount);
1182 }
1183 // Check if viewFormatCount is not zero that it is all compatible
1184 for (uint32_t i = 0; i < viewFormatCount; i++) {
1185 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1186 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1187 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1188 "VkImageCreateInfo::format (%s) are not compatible.",
1189 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1190 }
1191 }
1192 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001193 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001194
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001195 return skip;
1196}
1197
Jeff Bolz99e3f632020-03-24 22:59:22 -05001198bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1199 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1200 bool skip = false;
1201
1202 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001203 // Validate feature set if using CUBE_ARRAY
1204 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1205 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1206 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1207 "enabling the imageCubeArray feature.");
1208 }
1209
Jeff Bolz99e3f632020-03-24 22:59:22 -05001210 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1211 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1212 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001213 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001214 pCreateInfo->subresourceRange.layerCount);
1215 }
1216 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001217 skip |= LogError(
1218 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1219 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1220 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001221 }
1222 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001223
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001224 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001225 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1226 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1227 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1228 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1229 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1230 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1231 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1232 }
1233 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1234 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1235 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1236 "not an ASTC format.",
1237 string_VkFormat(pCreateInfo->format));
1238 }
1239 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001240
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001241 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001242 if (ycbcr_conversion != nullptr) {
1243 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1244 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1245 skip |= LogError(
1246 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1247 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1248 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1249 "r swizzle = %s\n"
1250 "g swizzle = %s\n"
1251 "b swizzle = %s\n"
1252 "a swizzle = %s\n",
1253 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1254 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1255 }
1256 }
1257 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001258 }
1259 return skip;
1260}
1261
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001262bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001263 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001264 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001265
1266 // Note: for numerical correctness
1267 // - float comparisons should expect NaN (comparison always false).
1268 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1269
1270 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001271 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001272 if (v1_f <= 0.0f) return true;
1273
1274 float intpart;
1275 const float fract = modff(v1_f, &intpart);
1276
1277 assert(std::numeric_limits<float>::radix == 2);
1278 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1279 if (intpart >= u32_max_plus1) return false;
1280
1281 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001282 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001283 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001284 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001285 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001286 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001287 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001288 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001289 };
1290
1291 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1292 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1293 return (v1_f <= v2_f);
1294 };
1295
1296 // width
1297 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001298 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001299
1300 if (!(viewport.width > 0.0f)) {
1301 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001302 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1303 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001304 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1305 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001306 skip |= LogError(object, "VUID-VkViewport-width-01771",
1307 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1308 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001309 }
1310
1311 // height
1312 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001313 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001314 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001315
1316 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1317 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001318 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1319 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001320 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1321 height_healthy = false;
1322
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001323 skip |= LogError(object, "VUID-VkViewport-height-01773",
1324 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1325 ").",
1326 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001327 }
1328
1329 // x
1330 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001331 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001332 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001333 skip |= LogError(object, "VUID-VkViewport-x-01774",
1334 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1335 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001336 }
1337
1338 // x + width
1339 if (x_healthy && width_healthy) {
1340 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001341 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001342 skip |= LogError(
1343 object, "VUID-VkViewport-x-01232",
1344 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1345 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1346 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001347 }
1348 }
1349
1350 // y
1351 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001352 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001353 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001354 skip |= LogError(object, "VUID-VkViewport-y-01775",
1355 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1356 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001357 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001358 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001359 skip |= LogError(object, "VUID-VkViewport-y-01776",
1360 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1361 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001362 }
1363
1364 // y + height
1365 if (y_healthy && height_healthy) {
1366 const float boundary = viewport.y + viewport.height;
1367
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001368 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001369 skip |= LogError(object, "VUID-VkViewport-y-01233",
1370 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1371 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1372 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001373 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001374 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001375 LogError(object, "VUID-VkViewport-y-01777",
1376 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1377 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1378 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001379 }
1380 }
1381
sfricke-samsungfd06d422021-01-22 02:17:21 -08001382 // 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 -07001383 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001384 // minDepth
1385 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001386 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001387 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001388 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1389 "[0.0, 1.0] range.",
1390 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001391 }
1392
1393 // maxDepth
1394 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001395 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001396 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001397 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1398 "[0.0, 1.0] range.",
1399 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001400 }
1401 }
1402
1403 return skip;
1404}
1405
Dave Houlton142c4cb2018-10-17 15:04:41 -06001406struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001407 VkShadingRatePaletteEntryNV shadingRate;
1408 uint32_t width;
1409 uint32_t height;
1410};
1411
1412// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001413static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001414 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1415 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1416 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1417 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1418 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1419 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001420};
1421
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001422bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001423 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001424
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001425 SampleOrderInfo *sample_order_info;
1426 uint32_t info_idx = 0;
1427 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1428 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1429 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001430 break;
1431 }
1432 }
1433
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001434 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001435 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1436 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1437 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001438 return skip;
1439 }
1440
Dave Houlton142c4cb2018-10-17 15:04:41 -06001441 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001442 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001443 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1444 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1445 ") must "
1446 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1447 "is set in framebufferNoAttachmentsSampleCounts.",
1448 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001449 }
1450
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001451 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001452 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1453 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1454 ") must "
1455 "be equal to the product of sampleCount (=%" PRIu32
1456 "), the fragment width for shadingRate "
1457 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001458 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001459 }
1460
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001461 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001462 skip |= LogError(
1463 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001464 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1465 ") must "
1466 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001467 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001468 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001469
1470 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001471 // the first width*height*sampleCount bits to all be set. Note: There is no
1472 // guarantee that 64 bits is enough, but practically it's unlikely for an
1473 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001474 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001475 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001476 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001477 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1478 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001479 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1480 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001481 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001482 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001483 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1484 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001485 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001486 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001487 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1488 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001489 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001490 uint32_t idx =
1491 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1492 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001493 }
1494
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001495 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1496 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001497 skip |= LogError(
1498 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001499 "The array pSampleLocations must contain exactly one entry for "
1500 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001501 }
1502
1503 return skip;
1504}
1505
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001506bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1507 uint32_t createInfoCount,
1508 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1509 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001510 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001511 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001512
1513 if (pCreateInfos != nullptr) {
1514 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001515 bool has_dynamic_viewport = false;
1516 bool has_dynamic_scissor = false;
1517 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001518 bool has_dynamic_depth_bias = false;
1519 bool has_dynamic_blend_constant = false;
1520 bool has_dynamic_depth_bounds = false;
1521 bool has_dynamic_stencil_compare = false;
1522 bool has_dynamic_stencil_write = false;
1523 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001524 bool has_dynamic_viewport_w_scaling_nv = false;
1525 bool has_dynamic_discard_rectangle_ext = false;
1526 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001527 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001528 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001529 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001530 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001531 bool has_dynamic_cull_mode = false;
1532 bool has_dynamic_front_face = false;
1533 bool has_dynamic_primitive_topology = false;
1534 bool has_dynamic_viewport_with_count = false;
1535 bool has_dynamic_scissor_with_count = false;
1536 bool has_dynamic_vertex_input_binding_stride = false;
1537 bool has_dynamic_depth_test_enable = false;
1538 bool has_dynamic_depth_write_enable = false;
1539 bool has_dynamic_depth_compare_op = false;
1540 bool has_dynamic_depth_bounds_test_enable = false;
1541 bool has_dynamic_stencil_test_enable = false;
1542 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001543 bool has_patch_control_points = false;
1544 bool has_rasterizer_discard_enable = false;
1545 bool has_depth_bias_enable = false;
1546 bool has_logic_op = false;
1547 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001548 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001549 if (pCreateInfos[i].pDynamicState != nullptr) {
1550 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1551 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1552 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001553 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1554 if (has_dynamic_viewport == true) {
1555 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1556 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1557 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1558 i);
1559 }
1560 has_dynamic_viewport = true;
1561 }
1562 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1563 if (has_dynamic_scissor == true) {
1564 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1565 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1566 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1567 i);
1568 }
1569 has_dynamic_scissor = true;
1570 }
1571 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1572 if (has_dynamic_line_width == true) {
1573 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1574 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1575 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1576 i);
1577 }
1578 has_dynamic_line_width = true;
1579 }
1580 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1581 if (has_dynamic_depth_bias == true) {
1582 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1583 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1584 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1585 i);
1586 }
1587 has_dynamic_depth_bias = true;
1588 }
1589 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1590 if (has_dynamic_blend_constant == true) {
1591 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1592 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1593 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1594 i);
1595 }
1596 has_dynamic_blend_constant = true;
1597 }
1598 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1599 if (has_dynamic_depth_bounds == true) {
1600 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1601 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1602 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1603 i);
1604 }
1605 has_dynamic_depth_bounds = true;
1606 }
1607 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1608 if (has_dynamic_stencil_compare == true) {
1609 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1610 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1611 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1612 i);
1613 }
1614 has_dynamic_stencil_compare = true;
1615 }
1616 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1617 if (has_dynamic_stencil_write == true) {
1618 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1619 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1620 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1621 i);
1622 }
1623 has_dynamic_stencil_write = true;
1624 }
1625 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1626 if (has_dynamic_stencil_reference == true) {
1627 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1628 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1629 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1630 i);
1631 }
1632 has_dynamic_stencil_reference = true;
1633 }
1634 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1635 if (has_dynamic_viewport_w_scaling_nv == true) {
1636 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1637 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1638 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1639 i);
1640 }
1641 has_dynamic_viewport_w_scaling_nv = true;
1642 }
1643 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1644 if (has_dynamic_discard_rectangle_ext == true) {
1645 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1646 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1647 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1648 i);
1649 }
1650 has_dynamic_discard_rectangle_ext = true;
1651 }
1652 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1653 if (has_dynamic_sample_locations_ext == true) {
1654 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1655 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1656 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1657 i);
1658 }
1659 has_dynamic_sample_locations_ext = true;
1660 }
1661 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1662 if (has_dynamic_exclusive_scissor_nv == true) {
1663 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1664 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1665 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1666 i);
1667 }
1668 has_dynamic_exclusive_scissor_nv = true;
1669 }
1670 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1671 if (has_dynamic_shading_rate_palette_nv == true) {
1672 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1673 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1674 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1675 i);
1676 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001677 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001678 }
1679 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1680 if (has_dynamic_viewport_course_sample_order_nv == true) {
1681 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1682 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1683 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1684 i);
1685 }
1686 has_dynamic_viewport_course_sample_order_nv = true;
1687 }
1688 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1689 if (has_dynamic_line_stipple == true) {
1690 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1691 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1692 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1693 i);
1694 }
1695 has_dynamic_line_stipple = true;
1696 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001697 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1698 if (has_dynamic_cull_mode) {
1699 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1700 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1701 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1702 i);
1703 }
1704 has_dynamic_cull_mode = true;
1705 }
1706 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1707 if (has_dynamic_front_face) {
1708 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1709 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1710 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1711 i);
1712 }
1713 has_dynamic_front_face = true;
1714 }
1715 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1716 if (has_dynamic_primitive_topology) {
1717 skip |= LogError(
1718 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1719 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1720 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1721 i);
1722 }
1723 has_dynamic_primitive_topology = true;
1724 }
1725 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1726 if (has_dynamic_viewport_with_count) {
1727 skip |= LogError(
1728 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1729 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1730 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1731 i);
1732 }
1733 has_dynamic_viewport_with_count = true;
1734 }
1735 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1736 if (has_dynamic_scissor_with_count) {
1737 skip |= LogError(
1738 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1739 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1740 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1741 i);
1742 }
1743 has_dynamic_scissor_with_count = true;
1744 }
1745 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1746 if (has_dynamic_vertex_input_binding_stride) {
1747 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1748 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1749 "listed twice in the "
1750 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1751 i);
1752 }
1753 has_dynamic_vertex_input_binding_stride = true;
1754 }
1755 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1756 if (has_dynamic_depth_test_enable) {
1757 skip |= LogError(
1758 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1759 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1760 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1761 i);
1762 }
1763 has_dynamic_depth_test_enable = true;
1764 }
1765 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1766 if (has_dynamic_depth_write_enable) {
1767 skip |= LogError(
1768 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1769 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1770 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1771 i);
1772 }
1773 has_dynamic_depth_write_enable = true;
1774 }
1775 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1776 if (has_dynamic_depth_compare_op) {
1777 skip |=
1778 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1779 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1780 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1781 i);
1782 }
1783 has_dynamic_depth_compare_op = true;
1784 }
1785 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1786 if (has_dynamic_depth_bounds_test_enable) {
1787 skip |= LogError(
1788 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1789 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1790 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1791 i);
1792 }
1793 has_dynamic_depth_bounds_test_enable = true;
1794 }
1795 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1796 if (has_dynamic_stencil_test_enable) {
1797 skip |= LogError(
1798 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1799 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1800 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1801 i);
1802 }
1803 has_dynamic_stencil_test_enable = true;
1804 }
1805 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1806 if (has_dynamic_stencil_op) {
1807 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1808 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1809 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1810 i);
1811 }
1812 has_dynamic_stencil_op = true;
1813 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001814 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1815 // Not allowed for graphics pipelines
1816 skip |= LogError(
1817 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1818 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1819 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1820 i, state_index);
1821 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001822 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1823 if (has_patch_control_points) {
1824 skip |= LogError(
1825 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1826 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1827 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1828 i);
1829 }
1830 has_patch_control_points = true;
1831 }
1832 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1833 if (has_rasterizer_discard_enable) {
1834 skip |= LogError(
1835 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1836 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1837 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1838 i);
1839 }
1840 has_rasterizer_discard_enable = true;
1841 }
1842 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1843 if (has_depth_bias_enable) {
1844 skip |= LogError(
1845 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1846 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1847 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1848 i);
1849 }
1850 has_depth_bias_enable = true;
1851 }
1852 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1853 if (has_logic_op) {
1854 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1855 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1856 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1857 i);
1858 }
1859 has_logic_op = true;
1860 }
1861 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1862 if (has_primitive_restart_enable) {
1863 skip |= LogError(
1864 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1865 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1866 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1867 i);
1868 }
1869 has_primitive_restart_enable = true;
1870 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001871 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1872 if (has_dynamic_vertex_input) {
1873 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1874 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1875 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1876 i);
1877 }
1878 has_dynamic_vertex_input = true;
1879 }
Petr Kraus299ba622017-11-24 03:09:03 +01001880 }
1881 }
1882
sfricke-samsung3b944422021-01-23 02:15:19 -08001883 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1884 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1885 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1886 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1887 i);
1888 }
1889
1890 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1891 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1892 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1893 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1894 i);
1895 }
1896
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001897 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001898 if ((feedback_struct != nullptr) &&
1899 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001900 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1901 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1902 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1903 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1904 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001905 }
1906
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001907 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001908
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001909 // Collect active stages and other information
1910 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001911 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001912 bool has_eval = false;
1913 bool has_control = false;
1914 if (pCreateInfos[i].pStages != nullptr) {
1915 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1916 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1917
1918 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1919 has_control = true;
1920 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1921 has_eval = true;
1922 }
1923
1924 skip |= validate_string(
1925 "vkCreateGraphicsPipelines",
1926 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1927 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1928 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001929 }
1930
1931 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1932 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1933 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1934 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1935 pCreateInfos[i].pTessellationState,
1936 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1937 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1938
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001939 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001940 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1941
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001942 skip |= validate_struct_pnext(
1943 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1944 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
1945 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
1946 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
1947 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1948 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001949
1950 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1951 pCreateInfos[i].pTessellationState->flags,
1952 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1953 }
1954
1955 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1956 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1957 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1958 pCreateInfos[i].pInputAssemblyState,
1959 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1960 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1961
1962 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1963 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001964 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001965
1966 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1967 pCreateInfos[i].pInputAssemblyState->flags,
1968 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1969
1970 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1971 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1972 pCreateInfos[i].pInputAssemblyState->topology,
1973 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1974
1975 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1976 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1977 }
1978
1979 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001980 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001981
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001982 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001983 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1984 "vkCreateGraphicsPipelines: pararameter "
1985 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1986 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001987 }
1988
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001989 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001990 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1991 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1992 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1993 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001994 allowed_structs_vk_pipeline_vertex_input_state_create_info,
1995 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08001996 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001997 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1998 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001999 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002000 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2001 skip |=
2002 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2003 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2004 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2005 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2006 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2007
2008 skip |= validate_array(
2009 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2010 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2011 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2012 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2013
2014 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002015 for (uint32_t vertex_binding_description_index = 0;
2016 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2017 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002018 skip |= validate_ranged_enum(
2019 "vkCreateGraphicsPipelines",
2020 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2021 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002022 pCreateInfos[i]
2023 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2024 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002025 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2026 }
2027 }
2028
2029 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002030 for (uint32_t vertex_attribute_description_index = 0;
2031 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2032 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002033 skip |= validate_ranged_enum(
2034 "vkCreateGraphicsPipelines",
2035 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2036 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002037 pCreateInfos[i]
2038 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2039 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002040 "VUID-VkVertexInputAttributeDescription-format-parameter");
2041 }
2042 }
2043
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002044 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002045 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2046 "vkCreateGraphicsPipelines: pararameter "
2047 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2048 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2049 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002050 }
2051
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002052 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002053 skip |=
2054 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2055 "vkCreateGraphicsPipelines: pararameter "
2056 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2057 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2058 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002059 }
2060
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002061 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002062 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2063 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002064 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2065 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002066 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2067 "vkCreateGraphicsPipelines: parameter "
2068 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2069 "(%" PRIu32 ") is not distinct.",
2070 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002071 }
2072 vertex_bindings.insert(vertex_bind_desc.binding);
2073
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002074 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002075 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2076 "vkCreateGraphicsPipelines: parameter "
2077 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2078 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2079 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002080 }
2081
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002082 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002083 skip |=
2084 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2085 "vkCreateGraphicsPipelines: parameter "
2086 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2087 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2088 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002089 }
2090 }
2091
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002092 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002093 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2094 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002095 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2096 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002097 skip |= LogError(
2098 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002099 "vkCreateGraphicsPipelines: parameter "
2100 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2101 i, d, vertex_attrib_desc.location);
2102 }
2103 attribute_locations.insert(vertex_attrib_desc.location);
2104
2105 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2106 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002107 skip |= LogError(
2108 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002109 "vkCreateGraphicsPipelines: parameter "
2110 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2111 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2112 i, d, vertex_attrib_desc.binding, i);
2113 }
2114
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002115 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002116 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2117 "vkCreateGraphicsPipelines: parameter "
2118 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2119 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2120 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002121 }
2122
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002123 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002124 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2125 "vkCreateGraphicsPipelines: parameter "
2126 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2127 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2128 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002129 }
2130
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002131 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002132 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2133 "vkCreateGraphicsPipelines: parameter "
2134 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2135 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2136 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002137 }
2138 }
2139 }
2140
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002141 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2142 if (has_control && has_eval) {
2143 if (pCreateInfos[i].pTessellationState == nullptr) {
2144 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2145 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2146 "shader stage and a tessellation evaluation shader stage, "
2147 "pCreateInfos[%d].pTessellationState must not be NULL.",
2148 i, i);
2149 } else {
2150 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2151 skip |= validate_struct_pnext(
2152 "vkCreateGraphicsPipelines",
2153 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2154 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2155 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2156 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002157
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002158 skip |= validate_reserved_flags(
2159 "vkCreateGraphicsPipelines",
2160 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2161 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002162
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002163 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2164 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2165 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2166 "vkCreateGraphicsPipelines: invalid parameter "
2167 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2168 "should be >0 and <=%u.",
2169 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2170 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002171 }
2172 }
2173 }
2174
2175 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2176 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2177 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2178 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002179 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2180 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2181 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2182 "].pViewportState (=NULL) is not a valid pointer.",
2183 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002184 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002185 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2186
2187 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002188 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2189 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2190 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2191 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002192 }
2193
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002194 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002195 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002196 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2197 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002198 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2199 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002200 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002201 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002202 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002203 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002204 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002205 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2206 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002207 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2208 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2209 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002210 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002211
2212 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002213 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002214 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002215 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002216
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002217 auto exclusive_scissor_struct =
2218 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2219 auto shading_rate_image_struct =
2220 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2221 auto coarse_sample_order_struct =
2222 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002223 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002224 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002225 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002226 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002227
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002228 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002229 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002230 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2231 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2232 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2233 ") is not 1.",
2234 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002235 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002236
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002237 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002238 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2239 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2240 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2241 ") is not 1.",
2242 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002243 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002244
Dave Houlton142c4cb2018-10-17 15:04:41 -06002245 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2246 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002247 skip |= LogError(
2248 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2249 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2250 "disabled, but pCreateInfos[%" PRIu32
2251 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2252 ") is not 1.",
2253 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002254 }
2255
Jeff Bolz9af91c52018-09-01 21:53:57 -05002256 if (shading_rate_image_struct &&
2257 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002258 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2259 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2260 "disabled, but pCreateInfos[%" PRIu32
2261 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2262 ") is neither 0 nor 1.",
2263 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002264 }
2265
Petr Krausa6103552017-11-16 21:21:58 +01002266 } else { // multiViewport enabled
2267 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002268 if (!has_dynamic_viewport_with_count) {
2269 skip |= LogError(
2270 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2271 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2272 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002273 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002274 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2275 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2276 "].pViewportState->viewportCount (=%" PRIu32
2277 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2278 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002279 } else if (has_dynamic_viewport_with_count) {
2280 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2281 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2282 "].pViewportState->viewportCount (=%" PRIu32
2283 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2284 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002285 }
Petr Krausa6103552017-11-16 21:21:58 +01002286
2287 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002288 if (!has_dynamic_scissor_with_count) {
2289 skip |= LogError(
2290 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2291 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2292 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002293 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002294 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2295 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2296 "].pViewportState->scissorCount (=%" PRIu32
2297 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2298 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002299 } else if (has_dynamic_scissor_with_count) {
2300 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2301 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2302 "].pViewportState->scissorCount (=%" PRIu32
2303 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2304 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002305 }
2306 }
2307
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002308 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002309 skip |=
2310 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2311 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2312 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2313 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002314 }
2315
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002316 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002317 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2318 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2319 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2320 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2321 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002322 }
2323
Piers Daniell39842ee2020-07-10 16:42:33 -06002324 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2325 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002326 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2327 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2328 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2329 "].pViewportState->viewportCount (=%" PRIu32 ").",
2330 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002331 }
2332
Dave Houlton142c4cb2018-10-17 15:04:41 -06002333 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002334 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002335 skip |=
2336 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2337 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2338 ") must be zero or identical to pCreateInfos[%" PRIu32
2339 "].pViewportState->viewportCount (=%" PRIu32 ").",
2340 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002341 }
2342
Dave Houlton142c4cb2018-10-17 15:04:41 -06002343 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002344 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002345 skip |= LogError(
2346 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002347 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2348 "] "
2349 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2350 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2351 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002352 }
2353
Petr Krausa6103552017-11-16 21:21:58 +01002354 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002355 skip |= LogError(
2356 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002357 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2358 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002359 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2360 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002361 }
2362
2363 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002364 skip |= LogError(
2365 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002366 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2367 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002368 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2369 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002370 }
2371
Jeff Bolz3e71f782018-08-29 23:15:45 -05002372 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002373 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2374 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2375 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002376 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002377 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2378 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2379 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2380 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002381 }
2382
Jeff Bolz9af91c52018-09-01 21:53:57 -05002383 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002384 shading_rate_image_struct->viewportCount > 0 &&
2385 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002386 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002387 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002388 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002389 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2390 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002391 i, i);
2392 }
2393
Chris Mayer328d8212018-12-11 14:16:18 +01002394 if (vp_swizzle_struct) {
2395 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002396 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2397 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2398 " does "
2399 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2400 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002401 }
2402 }
2403
Petr Krausb3fcdb42018-01-09 22:09:09 +01002404 // validate the VkViewports
2405 if (!has_dynamic_viewport && viewport_state.pViewports) {
2406 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2407 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002408 const char *fn_name = "vkCreateGraphicsPipelines";
2409 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2410 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2411 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002412 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002413 }
2414 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002415
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002416 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
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_VIEWPORT_W_SCALING_NV, but "
2420 "VK_NV_clip_space_w_scaling 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_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
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_DISCARD_RECTANGLE_EXT, but "
2428 "VK_EXT_discard_rectangles extension is not enabled.",
2429 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002430 }
2431
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002432 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
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_SAMPLE_LOCATIONS_EXT, but "
2436 "VK_EXT_sample_locations extension is not enabled.",
2437 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002438 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002440 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002441 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2442 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2443 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2444 "VK_NV_scissor_exclusive extension is not enabled.",
2445 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002446 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002447
2448 if (coarse_sample_order_struct &&
2449 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2450 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002451 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2452 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2453 "] "
2454 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2455 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2456 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002457 }
2458
2459 if (coarse_sample_order_struct) {
2460 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002461 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002462 }
2463 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002464
2465 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2466 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002467 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2468 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2469 "] "
2470 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2471 ") "
2472 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2473 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002474 }
2475 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002476 skip |= LogError(
2477 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002478 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2479 "] "
2480 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2481 i);
2482 }
2483 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002484 }
2485
2486 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002487 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2488 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2489 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2490 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002491 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002492 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002493 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002494 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2495 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002496 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002497 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002498 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002499 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002500 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002501 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002502 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002503 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2504 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002505
2506 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002507 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002508 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002509 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002510
2511 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002512 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002513 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2514 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2515
2516 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002517 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002518 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2519 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002520 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002521 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002522
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002523 skip |= validate_flags(
2524 "vkCreateGraphicsPipelines",
2525 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2526 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002527 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002528
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002529 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002530 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002531 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2532 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2533
2534 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002535 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002536 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2537 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2538
2539 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002540 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002541 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2542 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2543 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002544 }
John Zulauf7acac592017-11-06 11:15:53 -07002545 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002546 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002547 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2548 "vkCreateGraphicsPipelines(): parameter "
2549 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2550 i);
John Zulauf7acac592017-11-06 11:15:53 -07002551 }
2552 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2553 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2554 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002555 skip |= LogError(
2556 device,
2557
Dave Houlton413a6782018-05-22 13:01:54 -06002558 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002559 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002560 }
2561 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002562
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002563 const auto *line_state =
2564 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002565
2566 if (line_state) {
2567 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2568 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2569 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2570 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002571 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2572 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2573 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2574 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002575 }
2576 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2577 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002578 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2579 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2580 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2581 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002582 }
2583 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2584 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002585 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2586 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2587 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2588 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002589 }
2590 }
2591 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2592 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2593 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002594 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2595 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2596 "range [1,256].",
2597 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002598 }
2599 }
2600 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002601 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002602 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2603 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002604 skip |=
2605 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2606 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2607 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2608 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002609 }
2610 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2611 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002612 skip |=
2613 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2614 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2615 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2616 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002617 }
2618 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2619 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002620 skip |=
2621 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2622 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2623 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2624 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002625 }
2626 if (line_state->stippledLineEnable) {
2627 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2628 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002629 skip |=
2630 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2631 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2632 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2633 "stippledRectangularLines feature.",
2634 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002635 }
2636 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2637 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002638 skip |=
2639 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2640 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2641 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2642 "stippledBresenhamLines feature.",
2643 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002644 }
2645 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2646 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002647 skip |=
2648 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2649 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2650 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2651 "stippledSmoothLines feature.",
2652 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002653 }
2654 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2655 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002656 skip |=
2657 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2658 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2659 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2660 "stippledRectangularLines and strictLines features.",
2661 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002662 }
2663 }
2664 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002665 }
2666
Petr Krause91f7a12017-12-14 20:57:36 +01002667 bool uses_color_attachment = false;
2668 bool uses_depthstencil_attachment = false;
2669 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002670 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002671 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2672 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002673 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002674 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002675 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002676 }
2677 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002678 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002679 }
Petr Krause91f7a12017-12-14 20:57:36 +01002680 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002681 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002682 }
2683
2684 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002685 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002686 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002687 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002688 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002689 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002690
2691 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002692 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002693 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002694 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002695
2696 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002697 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002698 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2699 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2700
2701 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002702 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002703 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2704 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2705
2706 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002707 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2709 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002710 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002711
2712 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002713 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002714 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2715 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2716
2717 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002718 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002719 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2720 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2721
2722 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002723 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002724 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2725 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002726 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002727
2728 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002729 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002730 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2731 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002732 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002733
2734 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002735 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002736 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2737 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002738 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002739
2740 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002741 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002742 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2743 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002744 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002745
2746 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002747 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2749 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002750 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002751
2752 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002753 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002754 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2755 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002756 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002757
2758 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002759 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002760 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2761 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002762 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002763
2764 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002765 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002766 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2767 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002768 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002769
2770 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002771 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002772 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2773 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2774 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002775 }
2776 }
2777
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002778 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002779 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2780
Petr Krause91f7a12017-12-14 20:57:36 +01002781 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002782 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2783 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2784 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2785 pCreateInfos[i].pColorBlendState,
2786 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2787 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2788
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002789 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002790 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002791 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2792 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002793 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2794 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002795 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2796 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002797
2798 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002799 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002800 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002801 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802
2803 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002804 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002805 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2806 pCreateInfos[i].pColorBlendState->logicOpEnable);
2807
2808 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002809 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002810 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2811 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002812 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002813 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002814
2815 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002816 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2817 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002818 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002819 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002820 ParameterName::IndexVector{i, attachment_index}),
2821 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
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].srcColorBlendFactor",
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].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002829 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-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].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002834 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002836 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002837 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-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].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002842 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002843 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002844 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002845 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-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].srcAlphaBlendFactor",
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].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002853 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-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].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002858 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002859 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002860 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002861 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002862
2863 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002864 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002865 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002866 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002868 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002869 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870
2871 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002872 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002873 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002874 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002875 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002876 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002877 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002878 }
2879 }
2880
2881 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002882 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002883 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2884 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2885 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002886 }
2887
2888 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2889 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2890 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002891 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002893 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2894 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002895 }
2896 }
2897 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002898
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002899 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
2900 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01002901 if (pCreateInfos[i].basePipelineIndex != -1) {
2902 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002903 skip |=
2904 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002905 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002906 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002907 "and pCreateInfos->basePipelineIndex is not -1.",
2908 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002909 }
2910 }
2911
Petr Kraus9752aae2017-11-24 03:05:50 +01002912 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2913 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002914 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002915 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002916 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002917 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2918 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002919 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002920 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002921 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002922 skip |=
2923 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2924 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2925 "index into the pCreateInfos array, of size %d.",
2926 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002927 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002928 }
2929 }
2930
Petr Kraus9752aae2017-11-24 03:05:50 +01002931 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002932 if (!device_extensions.vk_nv_fill_rectangle) {
2933 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2934 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002935 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2936 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2937 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2938 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002939 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2940 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07002941 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002942 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002943 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2944 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2945 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002946 }
2947 } else {
2948 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2949 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2950 (physical_device_features.fillModeNonSolid == false)) {
2951 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002952 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2953 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002954 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2955 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2956 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002957 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958 }
Petr Kraus299ba622017-11-24 03:09:03 +01002959
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002960 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002961 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002962 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2963 "The line width state is static (pCreateInfos[%" PRIu32
2964 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2965 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2966 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2967 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002968 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002969 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002970
2971 // Validate no flags not allowed are used
2972 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07002973 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2974 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2975 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
2976 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002977 }
2978 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07002979 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
2980 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2981 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
2982 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002983 }
2984 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
2985 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07002986 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2987 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
2988 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002989 }
2990 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
2991 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07002992 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2993 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
2994 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002995 }
2996 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
2997 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07002998 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2999 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3000 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003001 }
3002 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3003 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003004 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3005 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3006 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003007 }
3008 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3009 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003010 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3011 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3012 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003013 }
3014 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3015 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003016 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3017 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3018 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003019 }
3020 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3021 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003022 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3023 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3024 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003025 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003026 }
3027 }
3028
3029 return skip;
3030}
3031
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003032bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3033 uint32_t createInfoCount,
3034 const VkComputePipelineCreateInfo *pCreateInfos,
3035 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003036 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003037 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003038 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003039 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003040 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003041 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003042 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003043 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003044 skip |=
3045 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3046 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3047 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3048 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003049 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003050
3051 // Make sure compute stage is selected
3052 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003053 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3054 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3055 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003056 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003057
sfricke-samsungeb549012021-04-16 01:25:51 -07003058 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3059 // Validate no flags not allowed are used
3060 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3061 skip |= LogError(
3062 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3063 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3064 i, flags);
3065 }
3066 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3067 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3068 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3069 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3070 i, flags);
3071 }
3072 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3073 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3074 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3075 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3076 i, flags);
3077 }
3078 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3079 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3080 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3081 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3082 i, flags);
3083 }
3084 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3085 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3086 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3087 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3088 i, flags);
3089 }
3090 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3091 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3092 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3093 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3094 i, flags);
3095 }
3096 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3097 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3098 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3099 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3100 i, flags);
3101 }
3102 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3103 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3104 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3105 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3106 i, flags);
3107 }
3108 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3109 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3110 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3111 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3112 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003113 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003114 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003115 return skip;
3116}
3117
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003118bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003119 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003120 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003121
3122 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003123 const auto &features = physical_device_features;
3124 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003125
John Zulauf71968502017-10-26 13:51:15 -06003126 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3127 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003128 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3129 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3130 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3131 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003132 }
3133
3134 // Anistropy cannot be enabled in sampler unless enabled as a feature
3135 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003136 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3137 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3138 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003139 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003140 }
John Zulauf71968502017-10-26 13:51:15 -06003141
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003142 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3143 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003144 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3145 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3146 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3147 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003148 }
3149 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003150 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3151 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3152 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3153 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003154 }
3155 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003156 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3157 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3158 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3159 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003160 }
3161 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3162 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3163 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3164 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003165 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3166 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3167 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3168 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3169 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3170 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003171 }
3172 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003173 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3174 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3175 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003176 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003177 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003178 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3179 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3180 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003181 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003182 }
3183
3184 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3185 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003186 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3187 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003188 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003189 if (sampler_reduction != nullptr) {
3190 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3191 skip |= LogError(
3192 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3193 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3194 }
3195 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003196 }
3197
3198 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3199 // valid VkBorderColor value
3200 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3201 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3202 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003203 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3204 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003205 }
3206
3207 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
3208 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003209 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003210 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
3211 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
3212 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06003213 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003214 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
3215 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
3216 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 }
John Zulauf275805c2017-10-26 15:34:49 -06003218
3219 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003220 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003221 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3222 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003223 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3224 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3225 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003226 }
3227 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003228
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003229 // Check for valid Lod range
3230 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003231 skip |=
3232 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3233 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003234 }
3235
3236 // Check mipLodBias to device limit
3237 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003238 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3239 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3240 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003241 }
3242
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003243 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003244 if (sampler_conversion != nullptr) {
3245 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3246 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3247 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3248 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003249 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003250 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003251 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3252 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3253 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3254 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3255 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3256 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3257 }
3258 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003259
3260 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3261 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3262 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3263 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3264 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3265 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3266 }
3267 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3268 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3269 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3270 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3271 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3272 }
3273 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3274 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3275 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3276 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3277 pCreateInfo->minLod, pCreateInfo->maxLod);
3278 }
3279 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3280 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3281 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3282 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3283 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3284 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3285 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3286 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3287 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3288 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3289 }
3290 if (pCreateInfo->anisotropyEnable) {
3291 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3292 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3293 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3294 }
3295 if (pCreateInfo->compareEnable) {
3296 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3297 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3298 "pCreateInfo->compareEnable must be VK_FALSE");
3299 }
3300 if (pCreateInfo->unnormalizedCoordinates) {
3301 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3302 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3303 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3304 }
3305 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003306 }
3307
Tony-LunarG7337b312020-04-15 16:40:25 -06003308 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3309 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3310 if (!device_extensions.vk_ext_custom_border_color) {
3311 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3312 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3313 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3314 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003315 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003316 if (!custom_create_info) {
3317 skip |=
3318 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3319 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3320 "struct in pNext chain.\n",
3321 string_VkBorderColor(pCreateInfo->borderColor));
3322 } else {
3323 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3324 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3325 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3326 !FormatIsSampledFloat(custom_create_info->format)))) {
3327 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3328 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3329 "whose type does not match\n",
3330 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3331 ;
3332 }
3333 }
3334 }
3335
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003336 return skip;
3337}
3338
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003339bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3340 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3341 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003342 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003343 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003344
3345 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3346 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3347 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3348 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003349 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3350 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3351 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3352 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3353 ++descriptor_index) {
3354 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003355 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003356 "vkCreateDescriptorSetLayout: required parameter "
3357 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3358 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003359 }
3360 }
3361 }
3362
3363 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3364 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3365 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003366 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3367 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3368 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3369 "values.",
3370 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003371 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003372
3373 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3374 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3375 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3376 skip |=
3377 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3378 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3379 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3380 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3381 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3382 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003383 }
3384 }
3385 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003386 return skip;
3387}
3388
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003389bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3390 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003391 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003392 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3393 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3394 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003395 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3396 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003397}
3398
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003399bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3400 const VkWriteDescriptorSet *pDescriptorWrites,
3401 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003402 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003403
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003404 if (pDescriptorWrites != NULL) {
3405 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3406 // descriptorCount must be greater than 0
3407 if (pDescriptorWrites[i].descriptorCount == 0) {
3408 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003409 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3410 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003411 }
3412
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003413 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3414 if (validateDstSet) {
3415 // dstSet must be a valid VkDescriptorSet handle
3416 skip |= validate_required_handle(vkCallingFunction,
3417 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3418 pDescriptorWrites[i].dstSet);
3419 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003420
3421 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3422 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3423 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3424 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3425 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3426 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3427 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003428 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3429 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003430 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003431 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3432 "%s(): if pDescriptorWrites[%d].descriptorType is "
3433 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3434 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3435 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3436 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003437 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3438 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003439 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3440 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003441 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3442 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003443 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003444 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3445 ParameterName::IndexVector{i, descriptor_index}),
3446 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003447 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003448 }
3449 }
3450 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3451 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3452 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3453 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3454 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3455 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3456 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003457 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003458 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003459 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3460 "%s(): if pDescriptorWrites[%d].descriptorType is "
3461 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3462 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3463 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3464 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003465 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003466 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003467 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003468 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003469 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3470 ++descriptor_index) {
3471 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3472 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3473 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003474 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3475 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003476 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003477 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3478 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003479 }
3480 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003481 }
3482 }
3483 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3484 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003485 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003486 }
3487
3488 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3489 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003490 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003491 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3492 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003493 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003494 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003495 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3496 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3497 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003498 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003499 }
3500 }
3501 }
3502 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3503 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003504 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003505 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3506 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003507 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003508 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003509 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3510 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3511 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003512 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003513 }
3514 }
3515 }
3516 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003517 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3518 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003519 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003520 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003521 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3522 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3523 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3524 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3525 "accelerationStructureCount %d member equals descriptorCount %d.",
3526 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3527 pDescriptorWrites[i].descriptorCount);
3528 }
3529 // further checks only if we have right structtype
3530 if (pnext_struct) {
3531 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3532 skip |= LogError(
3533 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3534 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3535 ".",
3536 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003537 }
sourav parmarbcee7512020-12-28 14:34:49 -08003538 if (pnext_struct->accelerationStructureCount == 0) {
3539 skip |= LogError(device,
3540 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3541 "%s(): accelerationStructureCount must be greater than 0 .");
3542 }
3543 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003544 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003545 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3546 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3547 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3548 skip |= LogError(device,
3549 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3550 "%s(): If the nullDescriptor feature is not enabled, each member of "
3551 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003552 }
3553 }
3554 }
sourav parmarbcee7512020-12-28 14:34:49 -08003555 }
3556 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003557 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003558 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3559 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3560 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3561 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3562 "accelerationStructureCount %d member equals descriptorCount %d.",
3563 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3564 pDescriptorWrites[i].descriptorCount);
3565 }
3566 // further checks only if we have right structtype
3567 if (pnext_struct) {
3568 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3569 skip |= LogError(
3570 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3571 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3572 ".",
3573 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003574 }
sourav parmarbcee7512020-12-28 14:34:49 -08003575 if (pnext_struct->accelerationStructureCount == 0) {
3576 skip |= LogError(device,
3577 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
3578 "%s(): accelerationStructureCount must be greater than 0 .");
3579 }
3580 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003581 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003582 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3583 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3584 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3585 skip |= LogError(device,
3586 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3587 "%s(): If the nullDescriptor feature is not enabled, each member of "
3588 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003589 }
3590 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003591 }
3592 }
3593 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003594 }
3595 }
3596 return skip;
3597}
3598
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003599bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3600 const VkWriteDescriptorSet *pDescriptorWrites,
3601 uint32_t descriptorCopyCount,
3602 const VkCopyDescriptorSet *pDescriptorCopies) const {
3603 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3604}
3605
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003606bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003607 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003608 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003609 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3610}
3611
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003612bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3613 const VkAllocationCallbacks *pAllocator,
3614 VkRenderPass *pRenderPass) const {
3615 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3616}
3617
Mike Schuchardt2df08912020-12-15 16:28:09 -08003618bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003619 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003620 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003621 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3622}
3623
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003624bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3625 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003626 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003627 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003628
3629 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3630 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3631 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003632 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3633 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003634 return skip;
3635}
3636
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003637bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003638 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003639 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003640
3641 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3642 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003643 bool cb_is_secondary;
3644 {
3645 auto lock = cb_read_lock();
3646 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3647 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003648
Tony-LunarG3c287f62020-12-17 12:39:49 -07003649 if (cb_is_secondary) {
3650 // Implicit VUs
3651 // validate only sType here; pointer has to be validated in core_validation
3652 const bool k_not_required = false;
3653 const char *k_no_vuid = nullptr;
3654 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3655 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003656 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3657 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003658
Tony-LunarG3c287f62020-12-17 12:39:49 -07003659 if (info) {
3660 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003661 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003662 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003663 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3664 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3665 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3666 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003667
Tony-LunarG3c287f62020-12-17 12:39:49 -07003668 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003669
Tony-LunarG3c287f62020-12-17 12:39:49 -07003670 // Explicit VUs
3671 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003672 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003673 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3674 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3675 cmd_name);
3676 }
3677
3678 if (physical_device_features.inheritedQueries) {
3679 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003680 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3681 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3682 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003683 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003684 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003685 }
3686
3687 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003688 skip |=
3689 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3690 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3691 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3692 } else { // !pipelineStatisticsQuery
3693 skip |=
3694 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3695 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003696 }
3697
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003698 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003699 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003700 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003701 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3702 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3703 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003704 commandBuffer,
3705 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003706 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3707 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3708 }
Petr Kraus139757b2019-08-15 17:19:33 +02003709 }
3710 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003711 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003712 return skip;
3713}
3714
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003715bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003716 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003717 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003718
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003719 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003720 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003721 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3722 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3723 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003724 }
3725 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003726 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3727 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3728 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003729 }
3730 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003731 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003732 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003733 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3734 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3735 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3736 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003737 }
3738 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003739
3740 if (pViewports) {
3741 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3742 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003743 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003744 skip |= manual_PreCallValidateViewport(
3745 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003746 }
3747 }
3748
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003749 return skip;
3750}
3751
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003752bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003753 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003754 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003755
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003756 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003757 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003758 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3759 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3760 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003761 }
3762 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003763 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3764 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3765 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003766 }
3767 } else { // multiViewport enabled
3768 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003769 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003770 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3771 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3772 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3773 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003774 }
3775 }
3776
Petr Kraus6260f0a2018-02-27 21:15:55 +01003777 if (pScissors) {
3778 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3779 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003780
Petr Kraus6260f0a2018-02-27 21:15:55 +01003781 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003782 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3783 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3784 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003785 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003786
Petr Kraus6260f0a2018-02-27 21:15:55 +01003787 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003788 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3789 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3790 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003791 }
3792
3793 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3794 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003795 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3796 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3797 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3798 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003799 }
3800
3801 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3802 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003803 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3804 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3805 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3806 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003807 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003808 }
3809 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003810
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003811 return skip;
3812}
3813
Jeff Bolz5c801d12019-10-09 10:38:45 -05003814bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003815 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003816
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003817 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003818 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3819 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003820 }
3821
3822 return skip;
3823}
3824
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003825bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003826 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003827 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003828
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003829 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003830 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003831 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3832 }
3833 if (drawCount > device_limits.maxDrawIndirectCount) {
3834 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003835 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3836 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003837 }
3838 return skip;
3839}
3840
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003841bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003842 VkDeviceSize offset, uint32_t drawCount,
3843 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003844 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003845 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003846 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3847 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3848 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003849 }
3850 if (drawCount > device_limits.maxDrawIndirectCount) {
3851 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003852 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3853 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003854 }
3855 return skip;
3856}
3857
sfricke-samsungf692b972020-05-02 08:00:45 -07003858bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3859 VkDeviceSize countBufferOffset, bool khr) const {
3860 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003861 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003862 if (offset & 3) {
3863 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003864 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003865 }
3866
3867 if (countBufferOffset & 3) {
3868 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003869 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003870 countBufferOffset);
3871 }
3872 return skip;
3873}
3874
3875bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(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, false);
3880}
3881
3882bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3883 VkDeviceSize offset, VkBuffer countBuffer,
3884 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3885 uint32_t stride) const {
3886 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3887}
3888
3889bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3890 VkDeviceSize countBufferOffset, bool khr) const {
3891 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003892 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003893 if (offset & 3) {
3894 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003895 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003896 }
3897
3898 if (countBufferOffset & 3) {
3899 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003900 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003901 countBufferOffset);
3902 }
3903 return skip;
3904}
3905
3906bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3907 VkDeviceSize offset, VkBuffer countBuffer,
3908 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3909 uint32_t stride) const {
3910 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3911}
3912
3913bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3914 VkDeviceSize offset, VkBuffer countBuffer,
3915 VkDeviceSize countBufferOffset,
3916 uint32_t maxDrawCount, uint32_t stride) const {
3917 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3918}
3919
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003920bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3921 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003922 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003923 bool skip = false;
3924 for (uint32_t rect = 0; rect < rectCount; rect++) {
3925 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003926 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3927 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003928 }
sfricke-samsung10867682020-04-25 02:20:39 -07003929 if (pRects[rect].rect.extent.width == 0) {
3930 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3931 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3932 }
3933 if (pRects[rect].rect.extent.height == 0) {
3934 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3935 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3936 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003937 }
3938 return skip;
3939}
3940
Andrew Fobel3abeb992020-01-20 16:33:22 -05003941bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3942 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3943 VkImageFormatProperties2 *pImageFormatProperties,
3944 const char *apiName) const {
3945 bool skip = false;
3946
3947 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003948 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003949 if (image_stencil_struct != nullptr) {
3950 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3951 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3952 // No flags other than the legal attachment bits may be set
3953 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3954 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003955 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3956 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3957 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3958 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3959 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003960 }
3961 }
3962 }
3963 }
3964
3965 return skip;
3966}
3967
3968bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3969 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3970 VkImageFormatProperties2 *pImageFormatProperties) const {
3971 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3972 "vkGetPhysicalDeviceImageFormatProperties2");
3973}
3974
3975bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3976 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3977 VkImageFormatProperties2 *pImageFormatProperties) const {
3978 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3979 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3980}
3981
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03003982bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
3983 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
3984 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
3985 bool skip = false;
3986
3987 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
3988 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
3989 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
3990 }
3991
3992 return skip;
3993}
3994
sfricke-samsung3999ef62020-02-09 17:05:59 -08003995bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3996 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3997 bool skip = false;
3998
3999 if (pRegions != nullptr) {
4000 for (uint32_t i = 0; i < regionCount; i++) {
4001 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004002 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4003 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004004 }
4005 }
4006 }
4007 return skip;
4008}
4009
Jeff Leger178b1e52020-10-05 12:22:23 -04004010bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4011 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4012 bool skip = false;
4013
4014 if (pCopyBufferInfo->pRegions != nullptr) {
4015 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4016 if (pCopyBufferInfo->pRegions[i].size == 0) {
4017 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4018 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4019 }
4020 }
4021 }
4022 return skip;
4023}
4024
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004025bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004026 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4027 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004028 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004029
4030 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004031 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4032 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4033 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004034 }
4035
4036 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004037 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4038 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4039 "), must be greater than zero and less than or equal to 65536.",
4040 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004041 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004042 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4043 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4044 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004045 }
4046 return skip;
4047}
4048
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004049bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004050 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004051 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004052
4053 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004054 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4055 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4056 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004057 }
4058
4059 if (size != VK_WHOLE_SIZE) {
4060 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004061 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004062 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4063 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004064 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004065 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4066 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004067 }
4068 }
4069 return skip;
4070}
4071
sfricke-samsunga1d00272021-03-10 21:37:41 -08004072bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004073 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004074
4075 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004076 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4077 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4078 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4079 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004080 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004081 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4082 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4083 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004084 }
4085
4086 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4087 // queueFamilyIndexCount uint32_t values
4088 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004089 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004090 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004091 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004092 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4093 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004094 }
4095 }
4096
Dave Houlton413a6782018-05-22 13:01:54 -06004097 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004098 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004099
sfricke-samsunga1d00272021-03-10 21:37:41 -08004100 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4101 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4102 if (format_list_info) {
4103 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4104 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4105 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4106 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4107 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4108 func_name, viewFormatCount);
4109 }
4110
4111 // Using the first format, compare the rest of the formats against it that they are compatible
4112 for (uint32_t i = 1; i < viewFormatCount; i++) {
4113 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4114 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4115 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4116 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4117 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4118 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4119 string_VkFormat(format_list_info->pViewFormats[i]));
4120 }
4121 }
4122 }
4123
4124 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4125 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4126 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4127 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4128 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4129 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4130 func_name);
4131 } else {
4132 if (format_list_info == nullptr) {
4133 skip |= LogError(
4134 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4135 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4136 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4137 func_name);
4138 } else if (format_list_info->viewFormatCount == 0) {
4139 skip |= LogError(
4140 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4141 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4142 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4143 func_name);
4144 } else {
4145 bool found_base_format = false;
4146 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4147 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4148 found_base_format = true;
4149 break;
4150 }
4151 }
4152 if (!found_base_format) {
4153 skip |=
4154 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4155 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4156 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4157 "pCreateInfo->imageFormat.",
4158 func_name);
4159 }
4160 }
4161 }
4162 }
4163 }
4164 return skip;
4165}
4166
4167bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4168 const VkAllocationCallbacks *pAllocator,
4169 VkSwapchainKHR *pSwapchain) const {
4170 bool skip = false;
4171 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4172 return skip;
4173}
4174
4175bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4176 const VkSwapchainCreateInfoKHR *pCreateInfos,
4177 const VkAllocationCallbacks *pAllocator,
4178 VkSwapchainKHR *pSwapchains) const {
4179 bool skip = false;
4180 if (pCreateInfos) {
4181 for (uint32_t i = 0; i < swapchainCount; i++) {
4182 std::stringstream func_name;
4183 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4184 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4185 }
4186 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004187 return skip;
4188}
4189
Jeff Bolz5c801d12019-10-09 10:38:45 -05004190bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004191 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004192
4193 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004194 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004195 if (present_regions) {
4196 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004197 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004198 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4199 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004200 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004201 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4202 "extension swapchainCount is %i. These values must be equal.",
4203 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004204 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004205 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004206 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4207 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004208 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4209 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4210 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004211 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004212 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004213 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004214 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004215 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004216 }
4217 }
4218
4219 return skip;
4220}
4221
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004222bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4223 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4224 const VkAllocationCallbacks *pAllocator,
4225 VkDisplayModeKHR *pMode) const {
4226 bool skip = false;
4227
4228 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4229 if (display_mode_parameters.visibleRegion.width == 0) {
4230 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4231 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4232 }
4233 if (display_mode_parameters.visibleRegion.height == 0) {
4234 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4235 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4236 }
4237 if (display_mode_parameters.refreshRate == 0) {
4238 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4239 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4240 }
4241
4242 return skip;
4243}
4244
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004245#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004246bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4247 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4248 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004249 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004250 bool skip = false;
4251
4252 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004253 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4254 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004255 }
4256
4257 return skip;
4258}
4259#endif // VK_USE_PLATFORM_WIN32_KHR
4260
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004261bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004262 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004263 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004264 bool skip = false;
4265
4266 if (pCreateInfo) {
4267 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004268 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4269 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004270 }
4271
4272 if (pCreateInfo->pPoolSizes) {
4273 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4274 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004275 skip |= LogError(
4276 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004277 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004278 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004279 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4280 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004281 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4282 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4283 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4284 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4285 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004286 }
Petr Krausc8655be2017-09-27 18:56:51 +02004287 }
4288 }
4289 }
4290
4291 return skip;
4292}
4293
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004294bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004295 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004296 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004297
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004298 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004299 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004300 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4301 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4302 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004303 }
4304
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004305 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004306 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004307 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4308 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4309 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004310 }
4311
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004312 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004313 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004314 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4315 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4316 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004317 }
4318
4319 return skip;
4320}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004321
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004322bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004323 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004324 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004325
4326 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004327 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4328 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004329 }
4330 return skip;
4331}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004332
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004333bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4334 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004335 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004336 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004337
4338 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004339 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004340 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004341 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4342 "vkCmdDispatch(): baseGroupX (%" PRIu32
4343 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4344 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004345 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004346 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4347 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4348 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4349 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004350 }
4351
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004352 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004353 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004354 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4355 "vkCmdDispatch(): baseGroupY (%" PRIu32
4356 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4357 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004358 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004359 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4360 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4361 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4362 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004363 }
4364
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004365 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004366 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004367 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4368 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4369 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4370 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004371 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004372 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4373 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4374 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4375 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004376 }
4377
4378 return skip;
4379}
4380
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004381bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4382 VkPipelineBindPoint pipelineBindPoint,
4383 VkPipelineLayout layout, uint32_t set,
4384 uint32_t descriptorWriteCount,
4385 const VkWriteDescriptorSet *pDescriptorWrites) const {
4386 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4387}
4388
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004389bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4390 uint32_t firstExclusiveScissor,
4391 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004392 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004393 bool skip = false;
4394
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004395 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004396 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004397 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004398 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4399 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4400 ") is not 0.",
4401 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004402 }
4403 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004404 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004405 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4406 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4407 ") is not 1.",
4408 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004409 }
4410 } else { // multiViewport enabled
4411 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004412 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004413 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4414 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4415 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4416 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004417 }
4418 }
4419
Jeff Bolz3e71f782018-08-29 23:15:45 -05004420 if (pExclusiveScissors) {
4421 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4422 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4423
4424 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004425 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4426 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4427 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004428 }
4429
4430 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004431 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4432 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4433 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004434 }
4435
4436 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4437 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004438 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4439 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4440 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4441 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004442 }
4443
4444 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4445 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004446 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4447 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4448 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4449 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004450 }
4451 }
4452 }
4453
4454 return skip;
4455}
4456
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004457bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4458 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004459 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004460 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004461 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4462 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4463 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4464 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4465 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4466 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004467 }
4468
4469 return skip;
4470}
4471
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004472bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4473 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004474 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004475 bool skip = false;
4476
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004477 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004478 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004479 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004480 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4481 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4482 ") is not 0.",
4483 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004484 }
4485 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004486 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004487 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4488 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4489 ") is not 1.",
4490 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004491 }
4492 }
4493
Jeff Bolz9af91c52018-09-01 21:53:57 -05004494 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004495 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004496 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4497 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4498 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4499 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004500 }
4501
4502 return skip;
4503}
4504
Jeff Bolz5c801d12019-10-09 10:38:45 -05004505bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4506 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4507 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004508 bool skip = false;
4509
Dave Houlton142c4cb2018-10-17 15:04:41 -06004510 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004511 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4512 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4513 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004514 }
4515
4516 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004517 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004518 }
4519
4520 return skip;
4521}
4522
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004523bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004524 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004525 bool skip = false;
4526
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004527 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004528 skip |= LogError(
4529 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004530 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4531 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004532 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004533 }
4534
4535 return skip;
4536}
4537
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004538bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4539 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004540 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004541 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004542 static const int condition_multiples = 0b0011;
4543 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004544 skip |= LogError(
4545 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004546 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004547 }
Lockee1c22882019-06-10 16:02:54 -06004548 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004549 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4550 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4551 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4552 stride);
Lockee1c22882019-06-10 16:02:54 -06004553 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004554 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004555 skip |= LogError(
4556 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4557 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004558 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004559 if (drawCount > device_limits.maxDrawIndirectCount) {
4560 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004561 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4562 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004563 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004564 return skip;
4565}
4566
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004567bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4568 VkDeviceSize offset, VkBuffer countBuffer,
4569 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004570 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004571 bool skip = false;
4572
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004573 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004574 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4575 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4576 "), is not a multiple of 4.",
4577 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004578 }
4579
4580 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004581 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4582 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4583 "), is not a multiple of 4.",
4584 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004585 }
4586
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004587 return skip;
4588}
4589
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004590bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004591 const VkAllocationCallbacks *pAllocator,
4592 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004593 bool skip = false;
4594
4595 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4596 if (pCreateInfo != nullptr) {
4597 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4598 // VkQueryPipelineStatisticFlagBits values
4599 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4600 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004601 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4602 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4603 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4604 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004605 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004606 if (pCreateInfo->queryCount == 0) {
4607 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4608 "vkCreateQueryPool(): queryCount must be greater than zero.");
4609 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004610 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004611 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004612}
4613
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004614bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4615 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004616 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004617 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4618 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004619}
4620
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004621void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004622 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4623 VkResult result) {
4624 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004625 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004626}
4627
Mike Schuchardt2df08912020-12-15 16:28:09 -08004628void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004629 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4630 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004631 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004632 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004633 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004634}
4635
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004636void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4637 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004638 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004639 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004640 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004641}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004642
Tony-LunarG3c287f62020-12-17 12:39:49 -07004643void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004644 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004645 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4646 auto lock = cb_write_lock();
4647 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004648 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004649 }
4650 }
4651}
4652
4653void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004654 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004655 auto lock = cb_write_lock();
4656 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4657 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4658 }
4659}
4660
4661void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004662 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004663 auto lock = cb_write_lock();
4664 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4665 if (item->second == commandPool) {
4666 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004667 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004668 ++item;
4669 }
4670 }
4671}
4672
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004673bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004674 const VkAllocationCallbacks *pAllocator,
4675 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004676 bool skip = false;
4677
4678 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004679 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004680 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004681 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4682 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004683 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004684
4685 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004686 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004687 if (flags_info) {
4688 flags = flags_info->flags;
4689 }
4690
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004691 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004692 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004693 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004694 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4695 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004696 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004697 }
4698
4699#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004700 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004701#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004702 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4703 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004704#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004705 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004706#endif
4707
4708 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004709 skip |= LogError(
4710 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004711 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4712 }
4713 if (
4714#ifdef VK_USE_PLATFORM_WIN32_KHR
4715 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4716#endif
4717 (import_memory_fd && import_memory_fd->handleType) ||
4718#ifdef VK_USE_PLATFORM_ANDROID_KHR
4719 (import_memory_ahb && import_memory_ahb->buffer) ||
4720#endif
4721 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004722 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4723 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004724 }
4725 }
4726
4727 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004728 VkBool32 capture_replay = false;
4729 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004730 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004731 if (vulkan_12_features) {
4732 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4733 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4734 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004735 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004736 if (bda_features) {
4737 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4738 buffer_device_address = bda_features->bufferDeviceAddress;
4739 }
4740 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004741 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004742 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004743 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004744 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004745 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004746 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004747 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004748 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004749 }
4750 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004751 }
4752 return skip;
4753}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004754
Jason Macnak192fa0e2019-07-26 15:07:16 -07004755bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004756 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004757 bool skip = false;
4758
4759 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4760 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4761 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004762 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004763 } else {
4764 uint32_t vertex_component_size = 0;
4765 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4766 vertex_component_size = 4;
4767 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4768 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4769 vertex_component_size = 2;
4770 }
4771 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004772 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004773 }
4774 }
4775
4776 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4777 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004778 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004779 } else {
4780 uint32_t index_element_size = 0;
4781 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4782 index_element_size = 4;
4783 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4784 index_element_size = 2;
4785 }
4786 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004787 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004788 }
4789 }
4790 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4791 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004792 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004793 }
4794 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004795 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004796 }
4797 }
4798
4799 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004800 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004801 }
4802
4803 return skip;
4804}
4805
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004806bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4807 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004808 bool skip = false;
4809
4810 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004811 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004812 }
4813 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004814 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004815 }
4816
4817 return skip;
4818}
4819
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004820bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4821 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004822 bool skip = false;
4823 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004824 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004825 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004826 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004827 }
4828 return skip;
4829}
4830
4831bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004832 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004833 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004834 bool skip = false;
4835 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004836 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4837 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4838 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004839 }
4840 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004841 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4842 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4843 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004844 }
4845 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4846 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004847 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4848 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4849 "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 -07004850 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004851 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004852 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004853 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4854 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004855 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4856 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004857 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004858 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004859 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4860 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4861 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004862 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004863 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004864 uint64_t total_triangle_count = 0;
4865 for (uint32_t i = 0; i < info.geometryCount; i++) {
4866 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004867
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004868 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004869
Jason Macnak5c954952019-07-09 15:46:12 -07004870 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4871 continue;
4872 }
4873 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4874 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004875 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004876 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4877 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4878 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004879 }
4880 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004881 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4882 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4883 for (uint32_t i = 1; i < info.geometryCount; i++) {
4884 const VkGeometryNV &geometry = info.pGeometries[i];
4885 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004886 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004887 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4888 "info.pGeometries[0].geometryType.",
4889 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004890 }
4891 }
4892 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004893 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4894 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4895 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4896 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4897 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4898 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4899 }
4900 }
4901 skip |=
4902 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004903 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004904 return skip;
4905}
4906
Ricardo Garciaa4935972019-02-21 17:43:18 +01004907bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4908 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004909 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004910 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004911 if (pCreateInfo) {
4912 if ((pCreateInfo->compactedSize != 0) &&
4913 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004914 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4915 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4916 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4917 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004918 }
Jason Macnak5c954952019-07-09 15:46:12 -07004919
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004920 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004921 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004922 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004923 return skip;
4924}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004925
Jeff Bolz5c801d12019-10-09 10:38:45 -05004926bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4927 const VkAccelerationStructureInfoNV *pInfo,
4928 VkBuffer instanceData, VkDeviceSize instanceOffset,
4929 VkBool32 update, VkAccelerationStructureNV dst,
4930 VkAccelerationStructureNV src, VkBuffer scratch,
4931 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004932 bool skip = false;
4933
4934 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004935 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004936 }
4937
4938 return skip;
4939}
4940
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004941bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4942 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4943 VkAccelerationStructureKHR *pAccelerationStructure) const {
4944 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004945 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004946 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004947 if (!acceleration_structure_features ||
4948 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
4949 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
4950 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
4951 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004952 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004953 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
4954 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004955 (acceleration_structure_features &&
4956 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07004957 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07004958 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
4959 "vkCreateAccelerationStructureKHR(): If createFlags includes "
4960 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
4961 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07004962 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004963 if (pCreateInfo->deviceAddress &&
4964 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
4965 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
4966 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
4967 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
4968 }
4969 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
4970 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
4971 "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset);
4972 }
sourav parmar83c31b12020-05-06 12:30:54 -07004973 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004974 return skip;
4975}
4976
Jason Macnak5c954952019-07-09 15:46:12 -07004977bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4978 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004979 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004980 bool skip = false;
4981 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004982 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4983 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004984 }
4985 return skip;
4986}
4987
sourav parmarcd5fb182020-07-17 12:58:44 -07004988bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
4989 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
4990 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4991 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004992 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004993 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
4994 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004995 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004996 }
4997 return skip;
4998}
4999
Peter Chen85366392019-05-14 15:20:11 -04005000bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5001 uint32_t createInfoCount,
5002 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5003 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005004 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005005 bool skip = false;
5006
5007 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005008 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005009 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005010 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005011 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5012 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5013 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5014 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005015 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005016
5017 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005018 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005019 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5020 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5021 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5022 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5023 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5024 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5025 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5026 }
5027 }
5028
sourav parmarf4a78252020-04-10 13:04:21 -07005029 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5030 skip |=
5031 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5032 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5033 }
5034 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5035 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5036 skip |=
5037 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5038 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5039 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5040 }
5041 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5042 if (pCreateInfos[i].basePipelineIndex != -1) {
5043 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5044 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5045 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5046 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5047 "and pCreateInfos->basePipelineIndex is not -1.");
5048 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005049 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005050 skip |=
5051 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5052 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5053 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5054 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5055 "that element.");
5056 }
sourav parmarf4a78252020-04-10 13:04:21 -07005057 }
5058 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005059 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005060 skip |=
5061 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5062 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5063 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5064 "commands pCreateInfos parameter.");
5065 }
5066 } else {
5067 if (pCreateInfos[i].basePipelineIndex != -1) {
5068 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5069 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5070 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5071 }
5072 }
5073 }
5074 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5075 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5076 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5077 }
5078 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5079 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5080 "vkCreateRayTracingPipelinesNV: flags must not include "
5081 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5082 }
5083 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5084 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5085 "vkCreateRayTracingPipelinesNV: flags must not include "
5086 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5087 }
5088 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5089 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5090 "vkCreateRayTracingPipelinesNV: flags must not include "
5091 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5092 }
5093 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5094 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5095 "vkCreateRayTracingPipelinesNV: flags must not include "
5096 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5097 }
5098 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5099 skip |= LogError(
5100 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5101 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5102 }
5103 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5104 skip |= LogError(
5105 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5106 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5107 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005108 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5109 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5110 "vkCreateRayTracingPipelinesNV: flags must not include "
5111 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5112 }
5113 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5114 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5115 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5116 }
Peter Chen85366392019-05-14 15:20:11 -04005117 }
5118
5119 return skip;
5120}
5121
sourav parmarcd5fb182020-07-17 12:58:44 -07005122bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5123 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5124 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005125 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005126 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005127 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5128 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5129 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005130 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005131 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005132 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5133 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5134 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5135 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5136 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5137 }
5138 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5139 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5140 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5141 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5142 }
5143 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005144 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005145 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5146 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005147 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5148 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5149 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005150 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5151 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5152 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005153 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005154 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005155 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5156 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5157 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5158 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005159 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005160 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5161 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5162 }
5163 }
sourav parmarf4a78252020-04-10 13:04:21 -07005164 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005165 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5166 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005167 }
5168 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005169 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005170 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005171 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5172 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005173 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005174 }
5175 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5176 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5177 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005178 }
5179 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5180 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5181 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5182 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5183 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5184 skip |= LogError(
5185 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005186 "vkCreateRayTracingPipelinesKHR: If flags includes "
5187 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005188 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5189 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5190 "must not be VK_SHADER_UNUSED_KHR");
5191 }
5192 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5193 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5194 skip |= LogError(
5195 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005196 "vkCreateRayTracingPipelinesKHR: If flags includes "
5197 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005198 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5199 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5200 "element must not be VK_SHADER_UNUSED_KHR");
5201 }
5202 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005203 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5204 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5205 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5206 skip |= LogError(
5207 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5208 "vkCreateRayTracingPipelinesKHR: If "
5209 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5210 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5211 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5212 }
5213 }
sourav parmarf4a78252020-04-10 13:04:21 -07005214 }
5215 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5216 if (pCreateInfos[i].basePipelineIndex != -1) {
5217 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5218 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005219 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005220 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5221 "and pCreateInfos->basePipelineIndex is not -1.");
5222 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005223 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005224 skip |=
5225 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5226 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5227 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5228 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5229 "element.");
5230 }
sourav parmarf4a78252020-04-10 13:04:21 -07005231 }
5232 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005233 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005234 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005235 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005236 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5237 "commands pCreateInfos parameter %d.",
5238 pCreateInfos[i].basePipelineIndex, createInfoCount);
5239 }
5240 } else {
5241 if (pCreateInfos[i].basePipelineIndex != -1) {
5242 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005243 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005244 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5245 }
5246 }
5247 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005248 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5249 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5250 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5251 "vkCreateRayTracingPipelinesKHR: If flags includes "
5252 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5253 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005254 }
5255 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5256 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5257 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5258 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5259 "pLibraryInfo and pLibraryInterface must be NULL.");
5260 }
5261 if (pCreateInfos[i].pLibraryInfo) {
5262 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5263 if (pCreateInfos[i].stageCount == 0) {
5264 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5265 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5266 "stageCount must not be 0.");
5267 }
5268 if (pCreateInfos[i].groupCount == 0) {
5269 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5270 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5271 "groupCount must not be 0.");
5272 }
5273 } else {
5274 if (pCreateInfos[i].pLibraryInterface == NULL) {
5275 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5276 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5277 "is greater than 0, its "
5278 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005279 }
5280 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005281 }
5282 if (pCreateInfos[i].pLibraryInterface) {
5283 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5284 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5285 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5286 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5287 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5288 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005289 }
5290 if (deferredOperation != VK_NULL_HANDLE) {
5291 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5292 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5293 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5294 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005295 }
5296 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005297 }
5298
5299 return skip;
5300}
5301
Mike Schuchardt21638df2019-03-16 10:52:02 -07005302#ifdef VK_USE_PLATFORM_WIN32_KHR
5303bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5304 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005305 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005306 bool skip = false;
5307 if (!device_extensions.vk_khr_swapchain)
5308 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
5309 if (!device_extensions.vk_khr_get_surface_capabilities_2)
5310 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5311 if (!device_extensions.vk_khr_surface)
5312 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
5313 if (!device_extensions.vk_khr_get_physical_device_properties_2)
5314 skip |=
5315 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5316 if (!device_extensions.vk_ext_full_screen_exclusive)
5317 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5318 skip |= validate_struct_type(
5319 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5320 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5321 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5322 if (pSurfaceInfo != NULL) {
5323 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5324 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5325 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5326
5327 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5328 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5329 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5330 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005331 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5332 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005333
5334 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5335 }
5336 return skip;
5337}
5338#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005339
5340bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5341 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005342 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005343 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5344 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005345 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005346 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5347 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5348 }
5349 return skip;
5350}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005351
5352bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005353 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005354 bool skip = false;
5355
5356 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005357 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5358 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005359 }
5360
5361 return skip;
5362}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005363
5364bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005365 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005366 bool skip = false;
5367
5368 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005369 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5370 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005371 }
5372
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005373 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005374 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005375 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5376 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005377 }
5378
5379 return skip;
5380}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005381
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005382bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5383 uint32_t bindingCount, const VkBuffer *pBuffers,
5384 const VkDeviceSize *pOffsets) const {
5385 bool skip = false;
5386 if (firstBinding > device_limits.maxVertexInputBindings) {
5387 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5388 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5389 device_limits.maxVertexInputBindings);
5390 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5391 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5392 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5393 "maxVertexInputBindings (%u)",
5394 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5395 }
5396
Jeff Bolz165818a2020-05-08 11:19:03 -05005397 for (uint32_t i = 0; i < bindingCount; ++i) {
5398 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005399 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005400 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5401 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5402 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5403 } else {
5404 if (pOffsets[i] != 0) {
5405 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5406 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5407 }
5408 }
5409 }
5410 }
5411
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005412 return skip;
5413}
5414
Mark Lobodzinski84988402019-09-11 15:27:30 -06005415bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005416 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005417 bool skip = false;
5418 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005419 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5420 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005421 }
5422 return skip;
5423}
5424
5425bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005426 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005427 bool skip = false;
5428 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005429 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5430 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005431 }
5432 return skip;
5433}
Petr Kraus3d720392019-11-13 02:52:39 +01005434
5435bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5436 VkSemaphore semaphore, VkFence fence,
5437 uint32_t *pImageIndex) const {
5438 bool skip = false;
5439
5440 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005441 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5442 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005443 }
5444
5445 return skip;
5446}
5447
5448bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5449 uint32_t *pImageIndex) const {
5450 bool skip = false;
5451
5452 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005453 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5454 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005455 }
5456
5457 return skip;
5458}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005459
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005460bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5461 uint32_t firstBinding, uint32_t bindingCount,
5462 const VkBuffer *pBuffers,
5463 const VkDeviceSize *pOffsets,
5464 const VkDeviceSize *pSizes) const {
5465 bool skip = false;
5466
5467 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5468 for (uint32_t i = 0; i < bindingCount; ++i) {
5469 if (pOffsets[i] & 3) {
5470 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5471 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5472 }
5473 }
5474
5475 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5476 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5477 "%s: The firstBinding(%" PRIu32
5478 ") index is greater than or equal to "
5479 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5480 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5481 }
5482
5483 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5484 skip |=
5485 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5486 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5487 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5488 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5489 }
5490
5491 for (uint32_t i = 0; i < bindingCount; ++i) {
5492 // pSizes is optional and may be nullptr.
5493 if (pSizes != nullptr) {
5494 if (pSizes[i] != VK_WHOLE_SIZE &&
5495 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5496 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5497 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5498 ") is not VK_WHOLE_SIZE and is greater than "
5499 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5500 cmd_name, i, pSizes[i]);
5501 }
5502 }
5503 }
5504
5505 return skip;
5506}
5507
5508bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5509 uint32_t firstCounterBuffer,
5510 uint32_t counterBufferCount,
5511 const VkBuffer *pCounterBuffers,
5512 const VkDeviceSize *pCounterBufferOffsets) const {
5513 bool skip = false;
5514
5515 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5516 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5517 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5518 "%s: The firstCounterBuffer(%" PRIu32
5519 ") index is greater than or equal to "
5520 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5521 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5522 }
5523
5524 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5525 skip |=
5526 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5527 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5528 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5529 cmd_name, firstCounterBuffer, counterBufferCount,
5530 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5531 }
5532
5533 return skip;
5534}
5535
5536bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5537 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5538 const VkBuffer *pCounterBuffers,
5539 const VkDeviceSize *pCounterBufferOffsets) const {
5540 bool skip = false;
5541
5542 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5543 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5544 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5545 "%s: The firstCounterBuffer(%" PRIu32
5546 ") index is greater than or equal to "
5547 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5548 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5549 }
5550
5551 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5552 skip |=
5553 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5554 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5555 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5556 cmd_name, firstCounterBuffer, counterBufferCount,
5557 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5558 }
5559
5560 return skip;
5561}
5562
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005563bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5564 uint32_t firstInstance, VkBuffer counterBuffer,
5565 VkDeviceSize counterBufferOffset,
5566 uint32_t counterOffset, uint32_t vertexStride) const {
5567 bool skip = false;
5568
5569 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005570 skip |= LogError(
5571 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005572 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5573 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5574 }
5575
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005576 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005577 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005578 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5579 }
5580
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005581 return skip;
5582}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005583
5584bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5585 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5586 const VkAllocationCallbacks *pAllocator,
5587 VkSamplerYcbcrConversion *pYcbcrConversion,
5588 const char *apiName) const {
5589 bool skip = false;
5590
5591 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005592 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005593 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005594 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005595 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5596 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005597 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005598 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005599 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005600
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005601#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005602 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005603 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005604#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005605 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005606#endif
5607
sfricke-samsung1a72f942020-07-25 12:09:18 -07005608 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005609
5610 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005611 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005612 const VkComponentMapping components = pCreateInfo->components;
5613 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5614 if (FormatIsXChromaSubsampled(format) == true) {
5615 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5616 skip |=
5617 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005618 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5619 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005620 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005621 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005622
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005623 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5624 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5625 skip |= LogError(
5626 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5627 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5628 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5629 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5630 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005631
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005632 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5633 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5634 skip |=
5635 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005636 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5637 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005638 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005639 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005640
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005641 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5642 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5643 skip |=
5644 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005645 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5646 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005647 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005648 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005649
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005650 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005651 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5652 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5653 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005654 skip |=
5655 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005656 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5657 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005658 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5659 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005660 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005661 }
5662
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005663 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5664 // Checks same VU multiple ways in order to give a more useful error message
5665 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5666 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5667 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5668 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5669 skip |= LogError(
5670 device, vuid,
5671 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5672 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5673 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5674 string_VkComponentSwizzle(components.b));
5675 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005676
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005677 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5678 // 4 channel format = no issue
5679 // 3 = no [a]
5680 // 2 = no [b,a]
5681 // 1 = no [g,b,a]
5682 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5683 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5684
5685 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5686 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5687 skip |= LogError(device, vuid,
5688 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5689 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5690 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5691 string_VkComponentSwizzle(components.b));
5692 } else if ((channels < 3) &&
5693 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5694 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5695 skip |= LogError(device, vuid,
5696 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5697 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5698 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5699 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5700 string_VkComponentSwizzle(components.b));
5701 } else if ((channels < 2) &&
5702 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5703 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5704 skip |= LogError(device, vuid,
5705 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5706 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5707 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5708 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5709 string_VkComponentSwizzle(components.b));
5710 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005711 }
5712 }
5713
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005714 return skip;
5715}
5716
5717bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5718 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5719 const VkAllocationCallbacks *pAllocator,
5720 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5721 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5722 "vkCreateSamplerYcbcrConversion");
5723}
5724
5725bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5726 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5727 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5728 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5729 "vkCreateSamplerYcbcrConversionKHR");
5730}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005731
5732bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5733 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5734 bool skip = false;
5735 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5736 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5737
5738 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005739 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5740 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5741 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5742 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5743 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005744 }
5745 return skip;
5746}
sourav parmara96ab1a2020-04-25 16:28:23 -07005747
5748bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005749 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005750 bool skip = false;
5751 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5752 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5753 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5754 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005755 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005756 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5757 skip |= LogError(
5758 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5759 "vkCopyAccelerationStructureToMemoryKHR: The "
5760 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5761 }
5762 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5763 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5764 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5765 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5766 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5767 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005768 return skip;
5769}
5770
5771bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5772 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5773 bool skip = false;
5774 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5775 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5776 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5777 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5778 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005779 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5780 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
5781 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.",
5782 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005783 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005784 return skip;
5785}
5786
5787bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5788 const char *api_name) const {
5789 bool skip = false;
5790 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5791 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5792 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5793 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5794 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5795 api_name);
5796 }
5797 return skip;
5798}
5799
5800bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005801 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005802 bool skip = false;
5803 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005804 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005805 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005806 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005807 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5808 "vkCopyAccelerationStructureKHR: The "
5809 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005810 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005811 return skip;
5812}
5813
5814bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5815 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5816 bool skip = false;
5817 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5818 return skip;
5819}
5820
5821bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005822 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005823 bool skip = false;
5824 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005825 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005826 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5827 }
5828 return skip;
5829}
5830
5831bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005832 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005833 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005834 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005835 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005836 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5837 skip |= LogError(
5838 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5839 "vkCopyMemoryToAccelerationStructureKHR: The "
5840 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005841 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005842 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
5843 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07005844 return skip;
5845}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005846
sourav parmara96ab1a2020-04-25 16:28:23 -07005847bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5848 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5849 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005850 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07005851 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
5852 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
5853 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.",
5854 pInfo->src.deviceAddress);
5855 }
sourav parmar83c31b12020-05-06 12:30:54 -07005856 return skip;
5857}
5858bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5859 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5860 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5861 bool skip = false;
5862 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5863 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5864 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5865 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5866 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5867 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5868 }
5869 return skip;
5870}
5871bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5872 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5873 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5874 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005875 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005876 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
5877 skip |= LogError(
5878 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
5879 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
5880 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5881 }
sourav parmar83c31b12020-05-06 12:30:54 -07005882 if (dataSize < accelerationStructureCount * stride) {
5883 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5884 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5885 "accelerationStructureCount (%d) *stride(%zu).",
5886 dataSize, accelerationStructureCount, stride);
5887 }
5888 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5889 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5890 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5891 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5892 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5893 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5894 }
5895 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5896 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5897 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5898 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5899 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5900 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5901 stride);
5902 }
5903 }
5904 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5905 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5906 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5907 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5908 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5909 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5910 stride);
5911 }
5912 }
sourav parmar83c31b12020-05-06 12:30:54 -07005913 return skip;
5914}
5915bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5916 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5917 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005918 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005919 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
5920 skip |= LogError(
5921 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
5922 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
5923 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07005924 }
5925 return skip;
5926}
5927
5928bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07005929 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5930 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
5931 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5932 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07005933 uint32_t width, uint32_t height, uint32_t depth) const {
5934 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005935 // RayGen
5936 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5937 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
5938 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005939 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005940 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5941 0) {
5942 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
5943 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5944 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5945 }
5946 // Callable
5947 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5948 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
5949 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5950 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005951 }
5952 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5953 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5954 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005955 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5956 }
5957 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5958 0) {
5959 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
5960 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5961 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005962 }
5963 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005964 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5965 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
5966 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5967 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005968 }
5969 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5970 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005971 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
5972 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07005973 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005974 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5975 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
5976 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5977 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5978 }
sourav parmar83c31b12020-05-06 12:30:54 -07005979 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005980 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5981 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
5982 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
5983 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07005984 }
5985 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5986 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5987 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005988 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5989 }
5990 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5991 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
5992 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5993 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5994 }
5995 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
5996 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
5997 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
5998 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
5999 }
6000 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6001 skip |=
6002 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6003 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6004 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006005 }
6006
sourav parmarcd5fb182020-07-17 12:58:44 -07006007 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6008 skip |=
6009 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6010 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6011 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6012 }
6013
6014 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6015 skip |=
6016 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6017 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6018 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006019 }
6020 return skip;
6021}
6022
sourav parmarcd5fb182020-07-17 12:58:44 -07006023bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6024 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6025 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6026 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006027 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006028 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006029 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6030 skip |= LogError(
6031 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6032 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6033 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006034 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006035 // RayGen
6036 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6037 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6038 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006039 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006040 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6041 0) {
6042 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6043 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6044 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6045 }
6046 // Callabe
6047 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6048 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6049 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6050 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006051 }
6052 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6053 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006054 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6055 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6056 }
6057 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6058 0) {
6059 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6060 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6061 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006062 }
6063 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006064 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6065 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6066 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6067 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006068 }
6069 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6070 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006071 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6072 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006073 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006074 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6075 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6076 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6077 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6078 }
sourav parmar83c31b12020-05-06 12:30:54 -07006079 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006080 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6081 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6082 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6083 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006084 }
6085 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6086 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006087 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6088 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6089 }
6090 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6091 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6092 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6093 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006094 }
6095
sourav parmarcd5fb182020-07-17 12:58:44 -07006096 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6097 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6098 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006099 }
6100 return skip;
6101}
6102bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6103 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6104 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6105 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6106 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6107 uint32_t width, uint32_t height, uint32_t depth) const {
6108 bool skip = false;
6109 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6110 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6111 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6112 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6113 }
6114 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6115 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6116 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6117 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6118 }
6119 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6120 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6121 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6122 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6123 }
6124
6125 // hitShader
6126 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6127 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6128 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6129 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6130 }
6131 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6132 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6133 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6134 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6135 }
6136 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6137 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6138 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6139 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6140 }
6141
6142 // missShader
6143 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6144 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6145 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6146 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6147 }
6148 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6149 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6150 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6151 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6152 }
6153 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6154 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6155 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6156 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6157 }
6158
6159 // raygenShader
6160 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6161 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6162 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006163 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6164 }
6165 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6166 skip |=
6167 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6168 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6169 }
6170 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6171 skip |=
6172 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6173 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6174 }
6175 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6176 skip |=
6177 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6178 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006179 }
6180 return skip;
6181}
6182
sourav parmar83c31b12020-05-06 12:30:54 -07006183bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006184 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6185 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006186 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006187 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6188 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006189 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6190 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006191 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006192 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6193 }
6194 return skip;
6195}
6196
Piers Daniell39842ee2020-07-10 16:42:33 -06006197bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6198 const VkViewport *pViewports) const {
6199 bool skip = false;
6200
6201 if (!physical_device_features.multiViewport) {
6202 if (viewportCount != 1) {
6203 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6204 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6205 ") is not 1.",
6206 viewportCount);
6207 }
6208 } else { // multiViewport enabled
6209 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6210 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6211 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6212 ") must "
6213 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6214 viewportCount, device_limits.maxViewports);
6215 }
6216 }
6217
6218 if (pViewports) {
6219 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6220 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6221 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6222 skip |= manual_PreCallValidateViewport(
6223 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6224 }
6225 }
6226
6227 return skip;
6228}
6229
6230bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6231 const VkRect2D *pScissors) const {
6232 bool skip = false;
6233
6234 if (!physical_device_features.multiViewport) {
6235 if (scissorCount != 1) {
6236 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6237 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6238 ") must "
6239 "be 1 when the multiViewport feature is disabled.",
6240 scissorCount);
6241 }
6242 } else { // multiViewport enabled
6243 if (scissorCount == 0) {
6244 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6245 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6246 ") must "
6247 "be great than zero.",
6248 scissorCount);
6249 } else if (scissorCount > device_limits.maxViewports) {
6250 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6251 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6252 ") must "
6253 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6254 scissorCount, device_limits.maxViewports);
6255 }
6256 }
6257
6258 if (pScissors) {
6259 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6260 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6261
6262 if (scissor.offset.x < 0) {
6263 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6264 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6265 scissor.offset.x);
6266 }
6267
6268 if (scissor.offset.y < 0) {
6269 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6270 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6271 scissor.offset.y);
6272 }
6273
6274 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6275 if (x_sum > INT32_MAX) {
6276 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6277 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6278 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6279 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6280 }
6281
6282 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6283 if (y_sum > INT32_MAX) {
6284 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6285 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6286 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6287 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6288 }
6289 }
6290 }
6291
6292 return skip;
6293}
6294
6295bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6296 uint32_t bindingCount, const VkBuffer *pBuffers,
6297 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6298 const VkDeviceSize *pStrides) const {
6299 bool skip = false;
6300 if (firstBinding >= device_limits.maxVertexInputBindings) {
6301 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6302 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6303 firstBinding, device_limits.maxVertexInputBindings);
6304 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6305 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6306 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6307 "maxVertexInputBindings (%u)",
6308 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6309 }
6310
6311 for (uint32_t i = 0; i < bindingCount; ++i) {
6312 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006313 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006314 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6315 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6316 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6317 } else {
6318 if (pOffsets[i] != 0) {
6319 skip |=
6320 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6321 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6322 }
6323 }
6324 }
6325 if (pStrides) {
6326 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6327 skip |=
6328 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
6329 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
6330 pStrides[i], device_limits.maxVertexInputBindingStride);
6331 }
6332 }
6333 }
6334
6335 return skip;
6336}
sourav parmarcd5fb182020-07-17 12:58:44 -07006337
6338bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6339 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6340 bool skip = false;
6341 for (uint32_t i = 0; i < infoCount; ++i) {
6342 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6343 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6344 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6345 }
6346 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6347 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6348 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6349 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6350 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6351 api_name);
6352 }
6353 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6354 skip |=
6355 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6356 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6357 }
6358 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6359 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6360 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6361 }
6362 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6363 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6364 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6365 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6366 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6367 api_name);
6368 }
6369 if (pInfos[i].pGeometries) {
6370 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6371 skip |= validate_ranged_enum(
6372 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6373 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6374 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6375 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006376 skip |= validate_struct_type(
6377 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6378 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6379 &(pInfos[i].pGeometries[j].geometry.triangles),
6380 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6381 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6382 skip |= validate_struct_pnext(
6383 api_name,
6384 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6385 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6386 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6387 skip |=
6388 validate_ranged_enum(api_name,
6389 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6390 ParameterName::IndexVector{i, j}),
6391 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6392 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6393 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6394 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6395 &pInfos[i].pGeometries[j].geometry.triangles,
6396 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6397 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6398 skip |= validate_ranged_enum(
6399 api_name,
6400 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6401 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6402 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6403
6404 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6405 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6406 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6407 }
6408 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6409 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6410 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6411 skip |=
6412 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6413 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6414 api_name);
6415 }
6416 }
6417 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6418 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6419 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6420 &pInfos[i].pGeometries[j].geometry.instances,
6421 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6422 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6423 skip |= validate_struct_type(
6424 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6425 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6426 &(pInfos[i].pGeometries[j].geometry.instances),
6427 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6428 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6429 skip |= validate_struct_pnext(
6430 api_name,
6431 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6432 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6433 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6434
6435 skip |= validate_bool32(api_name,
6436 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6437 ParameterName::IndexVector{i, j}),
6438 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6439 }
6440 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6441 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6442 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6443 &pInfos[i].pGeometries[j].geometry.aabbs,
6444 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6445 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6446 skip |= validate_struct_type(
6447 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6448 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6449 &(pInfos[i].pGeometries[j].geometry.aabbs),
6450 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6451 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6452 skip |= validate_struct_pnext(
6453 api_name,
6454 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6455 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6456 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6457 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6458 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6459 "(%s):stride must be less than or equal to 2^32-1", api_name);
6460 }
6461 }
6462 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6463 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6464 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6465 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6466 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6467 api_name);
6468 }
6469 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6470 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6471 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6472 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6473 "of elements of"
6474 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6475 api_name);
6476 }
6477 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6478 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6479 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6480 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6481 api_name);
6482 }
6483 }
6484 }
6485 }
6486 if (pInfos[i].ppGeometries != NULL) {
6487 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6488 skip |= validate_ranged_enum(
6489 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6490 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6491 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6492 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006493 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
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, true,
6497 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6498 skip |= validate_struct_type(
6499 api_name,
6500 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6501 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6502 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6503 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6504 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6505 skip |= validate_struct_pnext(
6506 api_name,
6507 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6508 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6509 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6510 skip |= validate_ranged_enum(api_name,
6511 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6512 ParameterName::IndexVector{i, j}),
6513 "VkFormat", AllVkFormatEnums,
6514 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6515 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6516 skip |= validate_ranged_enum(api_name,
6517 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6518 ParameterName::IndexVector{i, j}),
6519 "VkIndexType", AllVkIndexTypeEnums,
6520 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6521 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6522 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6523 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6524 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6525 }
6526 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6527 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6528 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6529 skip |=
6530 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6531 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6532 api_name);
6533 }
6534 }
6535 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6536 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
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, true,
6540 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6541 skip |= validate_struct_type(
6542 api_name,
6543 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6544 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6545 &(pInfos[i].ppGeometries[j]->geometry.instances),
6546 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6547 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6548 skip |= validate_struct_pnext(
6549 api_name,
6550 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6551 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6552 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6553 skip |= validate_bool32(api_name,
6554 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6555 ParameterName::IndexVector{i, j}),
6556 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6557 }
6558 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6559 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6560 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6561 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6562 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6563 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6564 skip |= validate_struct_type(
6565 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6566 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6567 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6568 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6569 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6570 skip |= validate_struct_pnext(
6571 api_name,
6572 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6573 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6574 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6575 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6576 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6577 "(%s):stride must be less than or equal to 2^32-1", api_name);
6578 }
6579 }
6580 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6581 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6582 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6583 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6584 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6585 api_name);
6586 }
6587 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6588 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6589 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6590 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6591 "of elements of"
6592 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6593 api_name);
6594 }
6595 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6596 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6597 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6598 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6599 api_name);
6600 }
6601 }
6602 }
6603 }
6604 }
6605 return skip;
6606}
6607bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6608 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6609 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6610 bool skip = false;
6611 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6612 for (uint32_t i = 0; i < infoCount; ++i) {
6613 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6614 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6615 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6616 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6617 "scratchData.deviceAddress member must be a multiple of "
6618 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6619 }
6620 for (uint32_t k = 0; k < infoCount; ++k) {
6621 if (i == k) continue;
6622 bool found = false;
6623 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6624 skip |= LogError(
6625 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6626 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6627 "not be "
6628 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6629 i, k);
6630 found = true;
6631 }
6632 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6633 skip |= LogError(
6634 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6635 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6636 "not be "
6637 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6638 i, k);
6639 found = true;
6640 }
6641 if (found) break;
6642 }
6643 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6644 if (pInfos[i].pGeometries) {
6645 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6646 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6647 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6648 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6649 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6650 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6651 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6652 }
6653 } else {
6654 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6655 skip |=
6656 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6657 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6658 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6659 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6660 }
6661 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006662 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006663 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6664 skip |= LogError(
6665 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6666 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6667 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6668 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006669 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6670 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006671 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6672 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6673 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6674 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6675 }
6676 }
6677 } else if (pInfos[i].ppGeometries) {
6678 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6679 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6680 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6681 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6682 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6683 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6684 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6685 }
6686 } else {
6687 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6688 skip |=
6689 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6690 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6691 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6692 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6693 }
6694 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006695 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006696 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6697 skip |= LogError(
6698 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6699 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6700 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6701 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006702 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6703 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006704 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6705 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6706 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6707 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6708 }
6709 }
6710 }
6711 }
6712 }
6713 return skip;
6714}
6715
6716bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6717 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6718 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6719 const uint32_t *const *ppMaxPrimitiveCounts) const {
6720 bool skip = false;
6721 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6722 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006723 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006724 if (!ray_tracing_acceleration_structure_features ||
6725 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6726 skip |= LogError(
6727 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6728 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6729 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6730 }
6731 for (uint32_t i = 0; i < infoCount; ++i) {
6732 if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) {
6733 if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) {
6734 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666",
6735 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is "
6736 "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be "
6737 "VK_NULL_HANDLE.");
6738 }
6739 }
6740 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6741 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6742 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6743 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6744 "scratchData.deviceAddress member must be a multiple of "
6745 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6746 }
6747 for (uint32_t k = 0; k < infoCount; ++k) {
6748 if (i == k) continue;
6749 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6750 skip |=
6751 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6752 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6753 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6754 "any other element [%d) of pInfos.",
6755 i, k);
6756 break;
6757 }
6758 }
6759 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6760 if (pInfos[i].pGeometries) {
6761 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6762 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6763 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6764 skip |= LogError(
6765 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6766 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6767 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6768 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6769 }
6770 } else {
6771 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6772 skip |= LogError(
6773 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6774 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6775 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6776 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6777 }
6778 }
6779 }
6780 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6781 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6782 skip |= LogError(
6783 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6784 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6785 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6786 }
6787 }
6788 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6789 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6790 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6791 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6792 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6793 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6794 }
6795 }
6796 } else if (pInfos[i].ppGeometries) {
6797 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6798 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6799 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6800 skip |= LogError(
6801 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6802 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6803 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6804 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6805 }
6806 } else {
6807 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6808 skip |= LogError(
6809 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6810 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6811 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6812 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6813 }
6814 }
6815 }
6816 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6817 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6818 skip |= LogError(
6819 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6820 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6821 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6822 }
6823 }
6824 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6825 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6826 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6827 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6828 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6829 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6830 }
6831 }
6832 }
6833 }
6834 }
6835 return skip;
6836}
6837
6838bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6839 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6840 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6841 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6842 bool skip = false;
6843 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6844 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006845 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006846 if (!ray_tracing_acceleration_structure_features ||
6847 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6848 skip |=
6849 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
6850 "vkBuildAccelerationStructuresKHR: The "
6851 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
6852 }
6853 for (uint32_t i = 0; i < infoCount; ++i) {
6854 for (uint32_t j = 0; j < infoCount; ++j) {
6855 if (i == j) continue;
6856 bool found = false;
6857 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6858 skip |= LogError(
6859 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6860 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
6861 "not be "
6862 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6863 i, j);
6864 found = true;
6865 }
6866 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6867 skip |= LogError(
6868 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
6869 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
6870 "not be "
6871 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6872 i, j);
6873 found = true;
6874 }
6875 if (found) break;
6876 }
6877 }
6878 return skip;
6879}
6880
6881bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
6882 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
6883 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
6884 bool skip = false;
6885 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
6886 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006887 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
6888 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006889 if (!(ray_tracing_pipeline_features || ray_query_features) ||
6890 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
6891 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
6892 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
6893 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
6894 }
6895 return skip;
6896}
sfricke-samsungecafb192021-01-17 08:21:14 -08006897
6898bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
6899 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
6900 const VkAllocationCallbacks *pAllocator,
6901 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
6902 bool skip = false;
6903 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
6904 if (private_data_features && private_data_features->privateData == VK_FALSE) {
6905 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
6906 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
6907 }
6908 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07006909}
Piers Daniellcb6d8032021-04-19 18:51:26 -06006910
6911bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
6912 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
6913 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
6914 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
6915 bool skip = false;
6916 const auto *vertex_input_dynamic_state_features =
6917 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
6918 const auto *vertex_attribute_divisor_features =
6919 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
6920
6921 // VUID-vkCmdSetVertexInputEXT-None-04790
6922 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
6923 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
6924 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
6925 }
6926
6927 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
6928 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
6929 skip |=
6930 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
6931 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
6932 }
6933
6934 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
6935 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
6936 skip |= LogError(
6937 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
6938 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
6939 }
6940
6941 // VUID-vkCmdSetVertexInputEXT-binding-04793
6942 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
6943 bool binding_found = false;
6944 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
6945 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
6946 binding_found = true;
6947 break;
6948 }
6949 }
6950 if (!binding_found) {
6951 skip |=
6952 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
6953 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
6954 }
6955 }
6956
6957 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
6958 if (vertexBindingDescriptionCount > 1) {
6959 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
6960 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
6961 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
6962 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
6963 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
6964 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
6965 }
6966 }
6967 }
6968 }
6969
6970 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
6971 if (vertexAttributeDescriptionCount > 1) {
6972 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
6973 uint32_t location = pVertexAttributeDescriptions[attribute].location;
6974 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
6975 if (location == pVertexAttributeDescriptions[next_attribute].location) {
6976 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
6977 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
6978 }
6979 }
6980 }
6981 }
6982
6983 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
6984 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
6985 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
6986 skip |= LogError(
6987 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
6988 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
6989 }
6990
6991 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
6992 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
6993 skip |= LogError(
6994 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
6995 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
6996 binding);
6997 }
6998
6999 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7000 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7001 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7002 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7003 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7004 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7005 binding);
7006 }
7007
7008 if (pVertexBindingDescriptions[binding].divisor > 1) {
7009 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7010 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7011 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7012 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7013 "vertexAttributeInstanceRateDivisor is not enabled",
7014 binding);
7015 } else {
7016 // VUID-VkVertexInputBindingDescription2EXT-divisor-04800
7017 if (pVertexBindingDescriptions[binding].divisor >
7018 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7019 skip |= LogError(
7020 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04800",
7021 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7022 binding);
7023 }
7024
7025 // VUID-VkVertexInputBindingDescription2EXT-divisor-04801
7026 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7027 skip |=
7028 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04801",
7029 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7030 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7031 binding);
7032 }
7033 }
7034 }
7035 }
7036
7037 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7038 // VUID-VkVertexInputAttributeDescription2EXT-location-04802
7039 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7040 skip |= LogError(
7041 device, "VUID-VkVertexInputAttributeDescription2EXT-location-04802",
7042 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7043 attribute);
7044 }
7045
7046 // VUID-VkVertexInputAttributeDescription2EXT-binding-04803
7047 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7048 skip |= LogError(
7049 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-04803",
7050 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7051 attribute);
7052 }
7053
7054 // VUID-VkVertexInputAttributeDescription2EXT-offset-04804
7055 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7056 skip |= LogError(
7057 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-04804",
7058 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7059 attribute);
7060 }
7061
7062 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7063 VkFormatProperties properties;
7064 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7065 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7066 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7067 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7068 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7069 attribute);
7070 }
7071 }
7072
7073 return skip;
7074}