blob: 260a9e3887bf240f68b1443cc911f85f189d5f11 [file] [log] [blame]
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070028static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060029
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070036read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); }
37write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); }
38
Jeremy Gebbencbf22862021-03-03 12:01:22 -070039static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070040static ReadWriteLock secondary_cb_map_mutex;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -070041static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); }
42static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070044bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050045 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060046 bool skip = false;
47
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070048 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060049
50 if (result == VK_STRING_ERROR_NONE) {
51 return skip;
52 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070053 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070054 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060055 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070056 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
57 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060058 }
59 return skip;
60}
61
Jeff Bolz46c0ea02019-10-09 13:06:29 -050062bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060063 bool skip = false;
64 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
65 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080066 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
67 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070068 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
69 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
70 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060071 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070072 skip |= LogWarning(instance, kVUIDUndefined,
73 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
74 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
75 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060076 }
77 }
78 return skip;
79}
80
Jeff Bolz46c0ea02019-10-09 13:06:29 -050081bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060082 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060083 // Create and use a local instance extension object, as an actual instance has not been created yet
84 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
85 InstanceExtensions local_instance_extensions;
86 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
87
John Zulauf620755c2018-04-16 11:00:43 -060088 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060089 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
90 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060091 }
92
93 return skip;
94}
95
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060096bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -070097 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060098 // Struct is legal IF it's supported
99 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
100 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
101 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
102 if (enum_iter != dev_exts_enumerated->second.cend()) {
103 return true;
104 }
105 }
106 return false;
107}
108
Tony-LunarG866843d2020-05-13 11:22:42 -0600109bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
110 const VkValidationFeaturesEXT *validation_features) const {
111 bool skip = false;
112 bool debug_printf = false;
113 bool gpu_assisted = false;
114 bool reserve_slot = false;
115 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
116 switch (validation_features->pEnabledValidationFeatures[i]) {
117 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
118 gpu_assisted = true;
119 break;
120
121 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
122 debug_printf = true;
123 break;
124
125 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
126 reserve_slot = true;
127 break;
128
129 default:
130 break;
131 }
132 }
133 if (reserve_slot && !gpu_assisted) {
134 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
135 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
136 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
137 }
138 if (gpu_assisted && debug_printf) {
139 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
140 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
141 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
142 }
143
144 return skip;
145}
146
John Zulauf620755c2018-04-16 11:00:43 -0600147template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700148ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
149 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600150 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700151 ExtEnabled state =
152 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600153 return state;
154}
155
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700156bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500157 const VkAllocationCallbacks *pAllocator,
158 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 bool skip = false;
160 // Note: From the spec--
161 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
162 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
163 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700164 ? pCreateInfo->pApplicationInfo->apiVersion
165 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700166 skip |= validate_api_version(local_api_version, api_version);
167 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700168 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600169 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
170
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700171 return skip;
172}
173
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700174void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700175 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
176 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700177 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
178 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700179 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700180 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700181}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600182
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700183void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
184 // Assume phys_devices is valid
185 assert(phys_devices);
186 for (int i = 0; i < count; ++i) {
187 const auto &phys_device = phys_devices[i];
188 if (0 == physical_device_properties_map.count(phys_device)) {
189 auto phys_dev_props = new VkPhysicalDeviceProperties;
190 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
191 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600192
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700193 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
194 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700195 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700196 std::vector<VkExtensionProperties> ext_props{};
197 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
198 ext_props.resize(ext_count);
199 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
200 for (uint32_t j = 0; j < ext_count; j++) {
201 dev_exts_enumerated.insert(ext_props[j].extensionName);
202 }
203 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600204 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700205 }
206}
207
208void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
209 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
210 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
211 return;
212 }
213
214 if (pPhysicalDeviceCount && pPhysicalDevices) {
215 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
216 }
217}
218
219void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
220 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
221 VkResult result) {
222 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
223 return;
224 }
225
226 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
227 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
228 const auto &group = pPhysicalDeviceGroupProperties[i];
229 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
230 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600231 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700232}
233
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600234void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
235 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
236 delete (it->second);
237 it = physical_device_properties_map.erase(it);
238 }
239};
240
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700241void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700242 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700243 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700244 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700245 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
246 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700247
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248 // Parmeter validation also uses extension data
249 stateless_validation->device_extensions = this->device_extensions;
250
251 VkPhysicalDeviceProperties device_properties = {};
252 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600253 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700254 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
255
256 if (device_extensions.vk_nv_shading_rate_image) {
257 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700258 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
259 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600260 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700261 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
262 }
263
264 if (device_extensions.vk_nv_mesh_shader) {
265 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700266 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
267 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600268 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700269 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
270 }
271
Jason Macnak5c954952019-07-09 15:46:12 -0700272 if (device_extensions.vk_nv_ray_tracing) {
273 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700274 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
275 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700276 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500277 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
278 }
279
sourav parmarcd5fb182020-07-17 12:58:44 -0700280 if (device_extensions.vk_khr_ray_tracing_pipeline) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500281 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700282 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
283 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500284 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
285 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700286 }
287
sourav parmarcd5fb182020-07-17 12:58:44 -0700288 if (device_extensions.vk_khr_acceleration_structure) {
289 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700290 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
291 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700292 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
293 phys_dev_ext_props.acc_structure_props = acc_structure_props;
294 }
295
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700296 if (device_extensions.vk_ext_transform_feedback) {
297 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700298 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
299 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700300 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
301 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
302 }
303
Piers Daniellcb6d8032021-04-19 18:51:26 -0600304 if (device_extensions.vk_ext_vertex_attribute_divisor) {
305 // Get the needed vertex attribute divisor limits
306 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
307 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
308 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
309 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
310 }
311
ziga-lunarga283d022021-08-04 18:35:23 +0200312 if (device_extensions.vk_ext_blend_operation_advanced) {
313 // Get the needed vertex attribute divisor limits
314 auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>();
315 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props);
316 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
317 phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props;
318 }
319
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800320 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
321
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700322 // Save app-enabled features in this device's validation object
323 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700324 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200325 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
326 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
327 if (features2) {
328 tmp_features2_state.features = features2->features;
329 } else if (pCreateInfo->pEnabledFeatures) {
330 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700331 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200332 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700333 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200334 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700335 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200336 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700337}
338
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700339bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500340 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600341 bool skip = false;
342
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200343 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
344 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
345 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600346 }
347
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700348 // If this device supports VK_KHR_portability_subset, it must be enabled
349 const std::string portability_extension_name("VK_KHR_portability_subset");
350 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
351 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
352 bool portability_requested = false;
353
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200354 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
355 skip |=
356 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
357 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
358 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
359 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700360 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
361 portability_requested = true;
362 }
363 }
364
365 if (portability_supported && !portability_requested) {
366 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
367 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
368 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600369 }
370
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200371 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700372 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
373 bool negative_viewport =
374 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200375 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700376 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
377 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
378 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200379 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600380 }
381
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600382 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200383 bool khr_bda =
384 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
385 bool ext_bda =
386 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600387 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700388 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
389 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
390 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600391 }
392 }
393
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600394 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
395 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700396 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600397 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800398 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700399 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800400 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700401 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600402 }
403 }
404
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700405 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500406 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700407 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500408 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
409 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
410 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
411 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700412 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700413 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
414 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
415 skip |= LogError(
416 device,
417 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
418 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
419 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700420 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700421 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600422 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
423 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
424 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
425 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600426 }
427
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700428 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700429 if (vulkan_11_features) {
430 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
431 while (current) {
432 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
433 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
434 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
435 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
436 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
437 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700438 skip |= LogError(
439 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700440 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
441 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
442 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
443 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
444 break;
445 }
446 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
447 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800448
449 // Check features are enabled if matching extension is passed in as well
450 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
451 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
452 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
453 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
454 skip |= LogError(
455 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
456 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
457 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
458 }
459 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700460 }
461
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700462 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700463 if (vulkan_12_features) {
464 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
465 while (current) {
466 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
467 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
469 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
470 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
471 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
472 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
473 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
474 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
475 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
476 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
477 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
478 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700479 skip |= LogError(
480 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700481 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
482 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
483 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
484 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
485 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
486 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
487 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
488 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
489 break;
490 }
491 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
492 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700493 // Check features are enabled if matching extension is passed in as well
494 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
495 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
496 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
497 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
498 skip |= LogError(
499 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
500 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
501 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
502 }
503 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
504 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
505 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
506 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
507 "is not VK_TRUE.",
508 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
509 }
510 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
511 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
512 skip |= LogError(
513 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
514 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
515 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
516 }
517 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
518 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
519 skip |= LogError(
520 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
521 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
522 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
523 }
524 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
525 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
526 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
527 skip |=
528 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
529 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
530 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
531 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
532 }
533 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200534 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
535 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
536 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
537 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
538 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
539 }
540 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700541 }
542
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600543 // Validate pCreateInfo->pQueueCreateInfos
544 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600545
546 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700547 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
548 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700550 skip |=
551 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
552 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
553 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
554 "index value.",
555 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600556 }
557
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700558 if (queue_create_info.pQueuePriorities != nullptr) {
559 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
560 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600561 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700562 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
563 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
564 "] (=%f) is not between 0 and 1 (inclusive).",
565 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600566 }
567 }
568 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700569
570 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700571 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700572 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700573 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700574 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700575 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700576 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700577 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700578 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700579 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700580 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
581 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
582 "protectedMemory feature being set as well.");
583 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600584 }
585 }
586
sfricke-samsung30a57412020-05-15 21:14:54 -0700587 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700588 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700589 VkBool32 variable_pointers = VK_FALSE;
590 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700591 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700592 variable_pointers = vulkan_11_features->variablePointers;
593 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700594 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700595 variable_pointers = variable_pointers_features->variablePointers;
596 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700597 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700598 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700599 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
600 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
601 }
602
sfricke-samsungfd76c342020-05-29 23:13:43 -0700603 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700604 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700605 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700606 VkBool32 multiview_geometry_shader = VK_FALSE;
607 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700608 if (vulkan_11_features) {
609 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700610 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
611 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700612 } else if (multiview_features) {
613 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700614 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
615 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700616 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700617 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700618 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
619 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
620 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700621 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700622 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
623 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
624 }
625
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 return skip;
627}
628
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500629bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700630 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700631 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
632 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
633 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600634 }
635
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700636 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600637}
638
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700639bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500640 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100641 bool skip = false;
642
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600643 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |=
645 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600646
647 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
648 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
649 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
650 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700651 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
652 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
653 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600654 }
655
656 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
657 // queueFamilyIndexCount uint32_t values
658 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700659 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
660 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
661 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
662 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600663 }
664 }
665
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700666 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
667 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
668 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
669 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
670 }
671
672 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
673 skip |=
674 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
675 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
676 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
677 }
678
679 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
680 skip |=
681 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
682 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
683 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
684 }
685
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600686 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
687 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
688 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
689 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700690 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
691 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
692 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600693 }
694 }
695
696 return skip;
697}
698
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700699bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500700 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600701 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600702
703 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800704 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700705 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600706 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
707 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
708 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
709 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
711 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
712 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600713 }
714
715 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
716 // queueFamilyIndexCount uint32_t values
717 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
719 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
720 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
721 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600722 }
723 }
724
Dave Houlton413a6782018-05-22 13:01:54 -0600725 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600727 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600729 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700730 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600731
Dave Houlton413a6782018-05-22 13:01:54 -0600732 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700733 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600734 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700735 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600736
Dave Houlton130c0212018-01-29 13:39:56 -0700737 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700738 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
739 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 skip |= LogError(
741 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600742 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
743 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700744 }
745
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600746 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100747 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
748 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700749 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
750 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
751 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600752 }
753
754 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700755 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100756 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700757 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
758 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
759 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
760 ") are not equal.",
761 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100762 }
763
764 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700765 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
766 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
767 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
768 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100769 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600770 }
771
772 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(
774 device, "VUID-VkImageCreateInfo-imageType-00957",
775 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600776 }
777 }
778
Dave Houlton130c0212018-01-29 13:39:56 -0700779 // 3D image may have only 1 layer
780 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
782 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700783 }
784
Dave Houlton130c0212018-01-29 13:39:56 -0700785 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
786 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
787 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
788 // At least one of the legal attachment bits must be set
789 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700790 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
791 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700792 }
793 // No flags other than the legal attachment bits may be set
794 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
795 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700796 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
797 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700798 }
799 }
800
Jeff Bolzef40fec2018-09-01 22:04:34 -0500801 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700802 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500803 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700804 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700805 ? static_cast<uint32_t>(ceil(log2(max_dim)))
806 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
807 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600808 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700809 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
810 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
811 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600812 }
813
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700814 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700815 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
816 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
817 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600818 }
819
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700820 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
822 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
823 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100824 }
825
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700826 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700827 skip |= LogError(
828 device, "VUID-VkImageCreateInfo-flags-01924",
829 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
830 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
831 }
832
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600833 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
834 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700835 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
836 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700837 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
838 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
839 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600840 }
841
842 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700843 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600844 // Linear tiling is unsupported
845 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700846 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700847 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
848 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600849 }
850
851 // Sparse 1D image isn't valid
852 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700853 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
854 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600855 }
856
857 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700858 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
860 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
861 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600862 }
863
864 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700865 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700866 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
867 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
868 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600869 }
870
871 // Multi-sample 2D image when device doesn't support it
872 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700873 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600874 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700875 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
876 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
877 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700878 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600879 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700880 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
881 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
882 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700883 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600884 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700885 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
886 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
887 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700888 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600889 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700890 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
891 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
892 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600893 }
894 }
895 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500896
Jeff Bolz9af91c52018-09-01 21:53:57 -0500897 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
898 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700899 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
900 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
901 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500902 }
903 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700904 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
905 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
906 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500907 }
908 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700909 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
910 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
911 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500912 }
913 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500914
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700915 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600916 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700917 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
918 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
919 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500920 }
921
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700922 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700923 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
924 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800925 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
926 "depth/stencil format.",
927 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500928 }
929
Dave Houlton142c4cb2018-10-17 15:04:41 -0600930 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700931 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
932 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
933 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
934 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500935 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600936 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700937 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
938 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
939 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
940 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500941 }
942 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500943
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700944 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800945 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700946 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
947 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800948 "format (%s) must be a depth or depth/stencil format.",
949 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700950 }
951
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700952 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500953 if (image_stencil_struct != nullptr) {
954 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
955 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
956 // No flags other than the legal attachment bits may be set
957 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
958 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700959 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
960 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
961 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
962 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500963 }
964 }
965
sfricke-samsung61a57c02021-01-10 21:35:12 -0800966 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500967 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
968 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800969 skip |= LogError(
970 device, "VUID-VkImageCreateInfo-Format-02536",
971 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
972 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
973 "maxFramebufferWidth (%u)",
974 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500975 }
976
977 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800978 skip |= LogError(
979 device, "VUID-VkImageCreateInfo-format-02537",
980 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
981 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
982 "maxFramebufferHeight (%u)",
983 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500984 }
985 }
986
987 if (!physical_device_features.shaderStorageImageMultisample &&
988 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
989 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
990 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700991 LogError(device, "VUID-VkImageCreateInfo-format-02538",
992 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
993 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
994 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500995 }
996
997 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
998 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700999 skip |= LogError(
1000 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001001 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1002 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1003 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1004 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1005 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001006 skip |= LogError(
1007 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001008 "vkCreateImage(): Depth-stencil image in which usage does not include "
1009 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1010 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1011 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1012 }
1013
1014 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1015 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001016 skip |= LogError(
1017 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001018 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1019 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1020 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1021 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1022 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001023 skip |= LogError(
1024 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001025 "vkCreateImage(): Depth-stencil image in which usage does not include "
1026 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1027 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1028 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1029 }
1030 }
1031 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001032
1033 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1034 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1035 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1036 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1037 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1038 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001039
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001040 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001041 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001042 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1043 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001044 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1045 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1046 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1047 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1048 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1049 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1050 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001051 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001052 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1053 } else if (drm_format_mod_list != nullptr) {
1054 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1055 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1056 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001057 }
1058 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1059 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1060 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1061 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1062 "in the pNext chain");
1063 }
1064 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001065
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001066 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001067 bool image_create_maybe_linear = false;
1068 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1069 image_create_maybe_linear = true;
1070 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1071 image_create_maybe_linear = false;
1072 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1073 image_create_maybe_linear =
1074 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001075 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001076 }
1077
1078 // If multi-sample, validate type, usage, tiling and mip levels.
1079 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001080 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001081 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1082 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1083 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1084 }
1085
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001086 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001087 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1088 image_create_maybe_linear)) {
1089 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1090 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1091 }
1092
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001093 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1094 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1095 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1096 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1097 "imageType must be VK_IMAGE_TYPE_2D.");
1098 }
1099 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1100 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1101 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1102 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1103 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001104 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001105 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001106 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1107 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1108 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1109 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1110 }
1111 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1112 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1113 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1114 "imageType must be VK_IMAGE_TYPE_2D.");
1115 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001116 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001117 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1118 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1119 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1120 }
1121 if (pCreateInfo->mipLevels != 1) {
1122 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1123 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1124 pCreateInfo->mipLevels);
1125 }
1126 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001127
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001128 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001129 if (swapchain_create_info != nullptr) {
1130 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1131 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1132 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1133 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1134 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1135 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1136
1137 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1138 // also implicitly forces the check above that extent.depth is 1
1139 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1140 string_VkImageType(pCreateInfo->imageType));
1141 }
1142 if (pCreateInfo->mipLevels != 1) {
1143 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1144 pCreateInfo->mipLevels);
1145 }
1146 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1147 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1148 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1149 }
1150 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1151 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1152 base_message, string_VkImageTiling(pCreateInfo->tiling));
1153 }
1154 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1155 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1156 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1157 }
1158 const VkImageCreateFlags valid_flags =
1159 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001160 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001161 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001162 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001163 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001164 }
1165 }
1166 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001167
1168 // If Chroma subsampled format ( _420_ or _422_ )
1169 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1170 skip |=
1171 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1172 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1173 ") must be a multiple of 2.",
1174 string_VkFormat(image_format), pCreateInfo->extent.width);
1175 }
1176 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1177 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1178 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1179 ") must be a multiple of 2.",
1180 string_VkFormat(image_format), pCreateInfo->extent.height);
1181 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001182
1183 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1184 if (format_list_info) {
1185 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1186 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1187 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1188 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1189 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1190 viewFormatCount);
1191 }
1192 // Check if viewFormatCount is not zero that it is all compatible
1193 for (uint32_t i = 0; i < viewFormatCount; i++) {
1194 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1195 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1196 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1197 "VkImageCreateInfo::format (%s) are not compatible.",
1198 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1199 }
1200 }
1201 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001202 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001203
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001204 return skip;
1205}
1206
Jeff Bolz99e3f632020-03-24 22:59:22 -05001207bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1208 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1209 bool skip = false;
1210
1211 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001212 // Validate feature set if using CUBE_ARRAY
1213 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1214 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1215 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1216 "enabling the imageCubeArray feature.");
1217 }
1218
Jeff Bolz99e3f632020-03-24 22:59:22 -05001219 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1220 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1221 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001222 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001223 pCreateInfo->subresourceRange.layerCount);
1224 }
1225 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001226 skip |= LogError(
1227 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1228 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1229 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001230 }
1231 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001232
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001233 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001234 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1235 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1236 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1237 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1238 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1239 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1240 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1241 }
1242 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1243 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1244 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1245 "not an ASTC format.",
1246 string_VkFormat(pCreateInfo->format));
1247 }
1248 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001249
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001250 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001251 if (ycbcr_conversion != nullptr) {
1252 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1253 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1254 skip |= LogError(
1255 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1256 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1257 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1258 "r swizzle = %s\n"
1259 "g swizzle = %s\n"
1260 "b swizzle = %s\n"
1261 "a swizzle = %s\n",
1262 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1263 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1264 }
1265 }
1266 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001267 }
1268 return skip;
1269}
1270
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001271bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001272 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001273 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001274
1275 // Note: for numerical correctness
1276 // - float comparisons should expect NaN (comparison always false).
1277 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1278
1279 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001280 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001281 if (v1_f <= 0.0f) return true;
1282
1283 float intpart;
1284 const float fract = modff(v1_f, &intpart);
1285
1286 assert(std::numeric_limits<float>::radix == 2);
1287 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1288 if (intpart >= u32_max_plus1) return false;
1289
1290 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001291 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001292 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001293 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001294 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001295 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001296 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001297 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001298 };
1299
1300 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1301 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1302 return (v1_f <= v2_f);
1303 };
1304
1305 // width
1306 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001307 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001308
1309 if (!(viewport.width > 0.0f)) {
1310 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001311 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1312 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001313 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1314 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001315 skip |= LogError(object, "VUID-VkViewport-width-01771",
1316 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1317 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001318 }
1319
1320 // height
1321 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001322 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001323 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001324
1325 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1326 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001327 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1328 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001329 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1330 height_healthy = false;
1331
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001332 skip |= LogError(object, "VUID-VkViewport-height-01773",
1333 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1334 ").",
1335 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001336 }
1337
1338 // x
1339 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001340 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001341 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001342 skip |= LogError(object, "VUID-VkViewport-x-01774",
1343 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1344 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001345 }
1346
1347 // x + width
1348 if (x_healthy && width_healthy) {
1349 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001350 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001351 skip |= LogError(
1352 object, "VUID-VkViewport-x-01232",
1353 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1354 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1355 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001356 }
1357 }
1358
1359 // y
1360 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001361 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001362 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001363 skip |= LogError(object, "VUID-VkViewport-y-01775",
1364 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1365 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001366 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001367 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001368 skip |= LogError(object, "VUID-VkViewport-y-01776",
1369 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1370 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001371 }
1372
1373 // y + height
1374 if (y_healthy && height_healthy) {
1375 const float boundary = viewport.y + viewport.height;
1376
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001377 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001378 skip |= LogError(object, "VUID-VkViewport-y-01233",
1379 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1380 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1381 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001382 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001383 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001384 LogError(object, "VUID-VkViewport-y-01777",
1385 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1386 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1387 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001388 }
1389 }
1390
sfricke-samsungfd06d422021-01-22 02:17:21 -08001391 // 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 -07001392 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001393 // minDepth
1394 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001395 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001396 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001397 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1398 "[0.0, 1.0] range.",
1399 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001400 }
1401
1402 // maxDepth
1403 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001404 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001405 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001406 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1407 "[0.0, 1.0] range.",
1408 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001409 }
1410 }
1411
1412 return skip;
1413}
1414
Dave Houlton142c4cb2018-10-17 15:04:41 -06001415struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001416 VkShadingRatePaletteEntryNV shadingRate;
1417 uint32_t width;
1418 uint32_t height;
1419};
1420
1421// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001422static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001423 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1424 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1425 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1426 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1427 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1428 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001429};
1430
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001431bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001432 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001433
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001434 SampleOrderInfo *sample_order_info;
1435 uint32_t info_idx = 0;
1436 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1437 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1438 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001439 break;
1440 }
1441 }
1442
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001443 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001444 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1445 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1446 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001447 return skip;
1448 }
1449
Dave Houlton142c4cb2018-10-17 15:04:41 -06001450 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001451 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001452 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1453 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1454 ") must "
1455 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1456 "is set in framebufferNoAttachmentsSampleCounts.",
1457 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001458 }
1459
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001460 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001461 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1462 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1463 ") must "
1464 "be equal to the product of sampleCount (=%" PRIu32
1465 "), the fragment width for shadingRate "
1466 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001467 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001468 }
1469
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001470 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001471 skip |= LogError(
1472 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001473 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1474 ") must "
1475 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001476 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001477 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001478
1479 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001480 // the first width*height*sampleCount bits to all be set. Note: There is no
1481 // guarantee that 64 bits is enough, but practically it's unlikely for an
1482 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001483 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001484 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001485 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001486 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1487 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001488 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1489 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001490 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001491 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001492 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1493 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001494 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001495 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001496 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1497 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001498 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001499 uint32_t idx =
1500 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1501 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001502 }
1503
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001504 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1505 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001506 skip |= LogError(
1507 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001508 "The array pSampleLocations must contain exactly one entry for "
1509 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001510 }
1511
1512 return skip;
1513}
1514
sfricke-samsung51303fb2021-05-09 19:09:13 -07001515bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1516 const VkAllocationCallbacks *pAllocator,
1517 VkPipelineLayout *pPipelineLayout) const {
1518 bool skip = false;
1519 // Validate layout count against device physical limit
1520 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1521 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
1522 "vkCreatePipelineLayout(): setLayoutCount (%d) exceeds physical device maxBoundDescriptorSets limit (%d).",
1523 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1524 }
1525
1526 // Validate Push Constant ranges
1527 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1528 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1529 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1530 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1531 // Check that offset + size don't exceed the max.
1532 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1533 if (offset >= max_push_constants_size) {
1534 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
1535 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) that exceeds this "
1536 "device's maxPushConstantSize of %u.",
1537 i, offset, max_push_constants_size);
1538 }
1539 if (size > max_push_constants_size - offset) {
1540 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
1541 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u] offset (%u) and size (%u) "
1542 "together exceeds this device's maxPushConstantSize of %u.",
1543 i, offset, size, max_push_constants_size);
1544 }
1545
1546 // size needs to be non-zero and a multiple of 4.
1547 if (size == 0) {
1548 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
1549 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not greater than zero.",
1550 i, size);
1551 }
1552 if (size & 0x3) {
1553 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
1554 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not a multiple of 4.", i,
1555 size);
1556 }
1557
1558 // offset needs to be a multiple of 4.
1559 if ((offset & 0x3) != 0) {
1560 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
1561 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) is not a multiple of 4.",
1562 i, offset);
1563 }
1564 }
1565
1566 // As of 1.0.28, there is a VU that states that a stage flag cannot appear more than once in the list of push constant ranges.
1567 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1568 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1569 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
1570 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1571 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %d and %d.", i, j);
1572 }
1573 }
1574 }
1575 return skip;
1576}
1577
ziga-lunargc6341372021-07-28 12:57:42 +02001578bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1579 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1580 bool skip = false;
1581
1582 const auto *required_subgroup_size_features =
1583 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1584
1585 if (required_subgroup_size_features) {
1586 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1587 skip |= LogError(
1588 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1589 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1590 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1591 func_name, msg, pCreateInfo->flags);
1592 }
1593 }
1594
1595 return skip;
1596}
1597
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001598bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1599 uint32_t createInfoCount,
1600 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1601 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001602 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001603 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001604
1605 if (pCreateInfos != nullptr) {
1606 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001607 bool has_dynamic_viewport = false;
1608 bool has_dynamic_scissor = false;
1609 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001610 bool has_dynamic_depth_bias = false;
1611 bool has_dynamic_blend_constant = false;
1612 bool has_dynamic_depth_bounds = false;
1613 bool has_dynamic_stencil_compare = false;
1614 bool has_dynamic_stencil_write = false;
1615 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001616 bool has_dynamic_viewport_w_scaling_nv = false;
1617 bool has_dynamic_discard_rectangle_ext = false;
1618 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001619 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001620 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001621 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001622 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001623 bool has_dynamic_cull_mode = false;
1624 bool has_dynamic_front_face = false;
1625 bool has_dynamic_primitive_topology = false;
1626 bool has_dynamic_viewport_with_count = false;
1627 bool has_dynamic_scissor_with_count = false;
1628 bool has_dynamic_vertex_input_binding_stride = false;
1629 bool has_dynamic_depth_test_enable = false;
1630 bool has_dynamic_depth_write_enable = false;
1631 bool has_dynamic_depth_compare_op = false;
1632 bool has_dynamic_depth_bounds_test_enable = false;
1633 bool has_dynamic_stencil_test_enable = false;
1634 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001635 bool has_patch_control_points = false;
1636 bool has_rasterizer_discard_enable = false;
1637 bool has_depth_bias_enable = false;
1638 bool has_logic_op = false;
1639 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001640 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001641 if (pCreateInfos[i].pDynamicState != nullptr) {
1642 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1643 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1644 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001645 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1646 if (has_dynamic_viewport == true) {
1647 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1648 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1649 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1650 i);
1651 }
1652 has_dynamic_viewport = true;
1653 }
1654 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1655 if (has_dynamic_scissor == true) {
1656 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1657 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1658 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1659 i);
1660 }
1661 has_dynamic_scissor = true;
1662 }
1663 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1664 if (has_dynamic_line_width == true) {
1665 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1666 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1667 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1668 i);
1669 }
1670 has_dynamic_line_width = true;
1671 }
1672 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1673 if (has_dynamic_depth_bias == true) {
1674 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1675 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1676 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1677 i);
1678 }
1679 has_dynamic_depth_bias = true;
1680 }
1681 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1682 if (has_dynamic_blend_constant == true) {
1683 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1684 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1685 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1686 i);
1687 }
1688 has_dynamic_blend_constant = true;
1689 }
1690 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1691 if (has_dynamic_depth_bounds == true) {
1692 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1693 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1694 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1695 i);
1696 }
1697 has_dynamic_depth_bounds = true;
1698 }
1699 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1700 if (has_dynamic_stencil_compare == true) {
1701 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1702 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1703 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1704 i);
1705 }
1706 has_dynamic_stencil_compare = true;
1707 }
1708 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1709 if (has_dynamic_stencil_write == true) {
1710 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1711 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1712 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1713 i);
1714 }
1715 has_dynamic_stencil_write = true;
1716 }
1717 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1718 if (has_dynamic_stencil_reference == true) {
1719 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1720 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1721 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1722 i);
1723 }
1724 has_dynamic_stencil_reference = true;
1725 }
1726 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1727 if (has_dynamic_viewport_w_scaling_nv == true) {
1728 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1729 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1730 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1731 i);
1732 }
1733 has_dynamic_viewport_w_scaling_nv = true;
1734 }
1735 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1736 if (has_dynamic_discard_rectangle_ext == true) {
1737 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1738 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1739 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1740 i);
1741 }
1742 has_dynamic_discard_rectangle_ext = true;
1743 }
1744 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1745 if (has_dynamic_sample_locations_ext == true) {
1746 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1747 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1748 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1749 i);
1750 }
1751 has_dynamic_sample_locations_ext = true;
1752 }
1753 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1754 if (has_dynamic_exclusive_scissor_nv == true) {
1755 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1756 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1757 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1758 i);
1759 }
1760 has_dynamic_exclusive_scissor_nv = true;
1761 }
1762 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1763 if (has_dynamic_shading_rate_palette_nv == true) {
1764 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1765 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1766 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1767 i);
1768 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001769 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001770 }
1771 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1772 if (has_dynamic_viewport_course_sample_order_nv == true) {
1773 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1774 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1775 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1776 i);
1777 }
1778 has_dynamic_viewport_course_sample_order_nv = true;
1779 }
1780 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1781 if (has_dynamic_line_stipple == true) {
1782 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1783 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1784 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1785 i);
1786 }
1787 has_dynamic_line_stipple = true;
1788 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001789 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1790 if (has_dynamic_cull_mode) {
1791 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1792 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1793 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1794 i);
1795 }
1796 has_dynamic_cull_mode = true;
1797 }
1798 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1799 if (has_dynamic_front_face) {
1800 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1801 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1802 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1803 i);
1804 }
1805 has_dynamic_front_face = true;
1806 }
1807 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1808 if (has_dynamic_primitive_topology) {
1809 skip |= LogError(
1810 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1811 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1812 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1813 i);
1814 }
1815 has_dynamic_primitive_topology = true;
1816 }
1817 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1818 if (has_dynamic_viewport_with_count) {
1819 skip |= LogError(
1820 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1821 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1822 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1823 i);
1824 }
1825 has_dynamic_viewport_with_count = true;
1826 }
1827 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1828 if (has_dynamic_scissor_with_count) {
1829 skip |= LogError(
1830 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1831 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1832 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1833 i);
1834 }
1835 has_dynamic_scissor_with_count = true;
1836 }
1837 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1838 if (has_dynamic_vertex_input_binding_stride) {
1839 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1840 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1841 "listed twice in the "
1842 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1843 i);
1844 }
1845 has_dynamic_vertex_input_binding_stride = true;
1846 }
1847 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1848 if (has_dynamic_depth_test_enable) {
1849 skip |= LogError(
1850 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1851 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1852 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1853 i);
1854 }
1855 has_dynamic_depth_test_enable = true;
1856 }
1857 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1858 if (has_dynamic_depth_write_enable) {
1859 skip |= LogError(
1860 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1861 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1862 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1863 i);
1864 }
1865 has_dynamic_depth_write_enable = true;
1866 }
1867 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1868 if (has_dynamic_depth_compare_op) {
1869 skip |=
1870 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1871 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1872 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1873 i);
1874 }
1875 has_dynamic_depth_compare_op = true;
1876 }
1877 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1878 if (has_dynamic_depth_bounds_test_enable) {
1879 skip |= LogError(
1880 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1881 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1882 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1883 i);
1884 }
1885 has_dynamic_depth_bounds_test_enable = true;
1886 }
1887 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1888 if (has_dynamic_stencil_test_enable) {
1889 skip |= LogError(
1890 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1891 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1892 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1893 i);
1894 }
1895 has_dynamic_stencil_test_enable = true;
1896 }
1897 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1898 if (has_dynamic_stencil_op) {
1899 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1900 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1901 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1902 i);
1903 }
1904 has_dynamic_stencil_op = true;
1905 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001906 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1907 // Not allowed for graphics pipelines
1908 skip |= LogError(
1909 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1910 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1911 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1912 i, state_index);
1913 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001914 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1915 if (has_patch_control_points) {
1916 skip |= LogError(
1917 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1918 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1919 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1920 i);
1921 }
1922 has_patch_control_points = true;
1923 }
1924 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1925 if (has_rasterizer_discard_enable) {
1926 skip |= LogError(
1927 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1928 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1929 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1930 i);
1931 }
1932 has_rasterizer_discard_enable = true;
1933 }
1934 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1935 if (has_depth_bias_enable) {
1936 skip |= LogError(
1937 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1938 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1939 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1940 i);
1941 }
1942 has_depth_bias_enable = true;
1943 }
1944 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1945 if (has_logic_op) {
1946 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1947 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1948 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1949 i);
1950 }
1951 has_logic_op = true;
1952 }
1953 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1954 if (has_primitive_restart_enable) {
1955 skip |= LogError(
1956 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1957 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1958 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1959 i);
1960 }
1961 has_primitive_restart_enable = true;
1962 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001963 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1964 if (has_dynamic_vertex_input) {
1965 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1966 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1967 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1968 i);
1969 }
1970 has_dynamic_vertex_input = true;
1971 }
Petr Kraus299ba622017-11-24 03:09:03 +01001972 }
1973 }
1974
sfricke-samsung3b944422021-01-23 02:15:19 -08001975 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1976 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1977 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1978 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1979 i);
1980 }
1981
1982 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1983 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1984 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1985 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1986 i);
1987 }
1988
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001989 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001990 if ((feedback_struct != nullptr) &&
1991 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001992 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1993 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1994 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1995 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1996 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001997 }
1998
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001999 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002000
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002001 // Collect active stages and other information
2002 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002003 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002004 bool has_eval = false;
2005 bool has_control = false;
2006 if (pCreateInfos[i].pStages != nullptr) {
2007 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
2008 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
2009
2010 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
2011 has_control = true;
2012 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
2013 has_eval = true;
2014 }
2015
2016 skip |= validate_string(
2017 "vkCreateGraphicsPipelines",
2018 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2019 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002020
2021 std::stringstream msg;
2022 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2023 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2024 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002025 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002026 }
2027
2028 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2029 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2030 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2031 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2032 pCreateInfos[i].pTessellationState,
2033 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2034 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2035
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002036 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002037 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2038
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002039 skip |= validate_struct_pnext(
2040 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2041 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2042 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2043 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2044 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2045 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002046
2047 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2048 pCreateInfos[i].pTessellationState->flags,
2049 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2050 }
2051
2052 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2053 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2054 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2055 pCreateInfos[i].pInputAssemblyState,
2056 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2057 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2058
2059 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2060 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002061 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002062
2063 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2064 pCreateInfos[i].pInputAssemblyState->flags,
2065 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2066
2067 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2068 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2069 pCreateInfos[i].pInputAssemblyState->topology,
2070 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2071
2072 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2073 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2074 }
2075
2076 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002077 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002078
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002079 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002080 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2081 "vkCreateGraphicsPipelines: pararameter "
2082 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
2083 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002084 }
2085
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002086 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002087 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2088 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2089 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2090 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002091 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2092 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002093 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002094 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2095 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002096 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002097 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2098 skip |=
2099 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2100 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2101 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2102 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2103 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2104
2105 skip |= validate_array(
2106 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2107 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2108 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2109 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2110
2111 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002112 for (uint32_t vertex_binding_description_index = 0;
2113 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2114 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002115 skip |= validate_ranged_enum(
2116 "vkCreateGraphicsPipelines",
2117 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2118 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002119 pCreateInfos[i]
2120 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2121 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002122 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2123 }
2124 }
2125
2126 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002127 for (uint32_t vertex_attribute_description_index = 0;
2128 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2129 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002130 skip |= validate_ranged_enum(
2131 "vkCreateGraphicsPipelines",
2132 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2133 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002134 pCreateInfos[i]
2135 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2136 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002137 "VUID-VkVertexInputAttributeDescription-format-parameter");
2138 }
2139 }
2140
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002141 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002142 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2143 "vkCreateGraphicsPipelines: pararameter "
2144 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2145 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2146 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002147 }
2148
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002149 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002150 skip |=
2151 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2152 "vkCreateGraphicsPipelines: pararameter "
2153 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2154 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2155 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002156 }
2157
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002158 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002159 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2160 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002161 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2162 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002163 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2164 "vkCreateGraphicsPipelines: parameter "
2165 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2166 "(%" PRIu32 ") is not distinct.",
2167 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002168 }
2169 vertex_bindings.insert(vertex_bind_desc.binding);
2170
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002171 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002172 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2173 "vkCreateGraphicsPipelines: parameter "
2174 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2175 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2176 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002177 }
2178
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002179 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002180 skip |=
2181 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2182 "vkCreateGraphicsPipelines: parameter "
2183 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2184 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2185 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002186 }
2187 }
2188
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002189 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002190 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2191 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002192 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2193 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002194 skip |= LogError(
2195 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002196 "vkCreateGraphicsPipelines: parameter "
2197 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2198 i, d, vertex_attrib_desc.location);
2199 }
2200 attribute_locations.insert(vertex_attrib_desc.location);
2201
2202 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2203 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002204 skip |= LogError(
2205 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002206 "vkCreateGraphicsPipelines: parameter "
2207 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2208 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2209 i, d, vertex_attrib_desc.binding, i);
2210 }
2211
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002212 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002213 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2214 "vkCreateGraphicsPipelines: parameter "
2215 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2216 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2217 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002218 }
2219
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002220 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002221 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2222 "vkCreateGraphicsPipelines: parameter "
2223 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2224 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2225 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002226 }
2227
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002228 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002229 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2230 "vkCreateGraphicsPipelines: parameter "
2231 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2232 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2233 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002234 }
2235 }
2236 }
2237
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002238 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2239 if (has_control && has_eval) {
2240 if (pCreateInfos[i].pTessellationState == nullptr) {
2241 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2242 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2243 "shader stage and a tessellation evaluation shader stage, "
2244 "pCreateInfos[%d].pTessellationState must not be NULL.",
2245 i, i);
2246 } else {
2247 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2248 skip |= validate_struct_pnext(
2249 "vkCreateGraphicsPipelines",
2250 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2251 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2252 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2253 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002254
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002255 skip |= validate_reserved_flags(
2256 "vkCreateGraphicsPipelines",
2257 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2258 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002259
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002260 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2261 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2262 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2263 "vkCreateGraphicsPipelines: invalid parameter "
2264 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2265 "should be >0 and <=%u.",
2266 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2267 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002268 }
2269 }
2270 }
2271
2272 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2273 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2274 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2275 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002276 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2277 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2278 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2279 "].pViewportState (=NULL) is not a valid pointer.",
2280 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002281 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002282 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2283
2284 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002285 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2286 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2287 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2288 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002289 }
2290
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002291 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002292 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002293 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2294 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002295 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2296 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002297 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002299 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002300 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002301 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002302 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2303 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002304 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2305 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2306 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002307 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002308
2309 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002310 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002311 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002312 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002313
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002314 auto exclusive_scissor_struct =
2315 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2316 auto shading_rate_image_struct =
2317 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2318 auto coarse_sample_order_struct =
2319 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002320 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002321 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002322 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002323 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002324
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002325 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002326 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002327 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2328 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2329 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2330 ") is not 1.",
2331 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002332 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002333
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002334 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002335 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2336 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2337 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2338 ") is not 1.",
2339 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002340 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002341
Dave Houlton142c4cb2018-10-17 15:04:41 -06002342 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2343 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002344 skip |= LogError(
2345 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2346 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2347 "disabled, but pCreateInfos[%" PRIu32
2348 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2349 ") is not 1.",
2350 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002351 }
2352
Jeff Bolz9af91c52018-09-01 21:53:57 -05002353 if (shading_rate_image_struct &&
2354 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002355 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2356 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2357 "disabled, but pCreateInfos[%" PRIu32
2358 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2359 ") is neither 0 nor 1.",
2360 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002361 }
2362
Petr Krausa6103552017-11-16 21:21:58 +01002363 } else { // multiViewport enabled
2364 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002365 if (!has_dynamic_viewport_with_count) {
2366 skip |= LogError(
2367 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2368 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2369 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002370 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002371 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2372 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2373 "].pViewportState->viewportCount (=%" PRIu32
2374 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2375 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002376 } else if (has_dynamic_viewport_with_count) {
2377 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2378 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2379 "].pViewportState->viewportCount (=%" PRIu32
2380 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2381 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002382 }
Petr Krausa6103552017-11-16 21:21:58 +01002383
2384 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002385 if (!has_dynamic_scissor_with_count) {
2386 skip |= LogError(
2387 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2388 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2389 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002390 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002391 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2392 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2393 "].pViewportState->scissorCount (=%" PRIu32
2394 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2395 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002396 } else if (has_dynamic_scissor_with_count) {
2397 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2398 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2399 "].pViewportState->scissorCount (=%" PRIu32
2400 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2401 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002402 }
2403 }
2404
ziga-lunarg845883b2021-07-14 15:05:00 +02002405 if (!has_dynamic_scissor && viewport_state.pScissors) {
2406 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2407 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002408
2409 if (scissor.offset.x < 0) {
2410 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2411 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2412 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2413 scissor.offset.x, i, scissor_i);
2414 }
2415
2416 if (scissor.offset.y < 0) {
2417 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2418 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2419 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2420 scissor.offset.y, i, scissor_i);
2421 }
2422
ziga-lunarg845883b2021-07-14 15:05:00 +02002423 const int64_t x_sum =
2424 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2425 if (x_sum > std::numeric_limits<int32_t>::max()) {
2426 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2427 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2428 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2429 "] will overflow int32_t.",
2430 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2431 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002432
ziga-lunarg845883b2021-07-14 15:05:00 +02002433 const int64_t y_sum =
2434 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2435 if (y_sum > std::numeric_limits<int32_t>::max()) {
2436 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2437 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2438 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2439 "] will overflow int32_t.",
2440 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2441 }
2442 }
2443 }
2444
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002445 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002446 skip |=
2447 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2448 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2449 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2450 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002451 }
2452
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002453 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002454 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2455 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2456 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2457 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2458 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002459 }
2460
Piers Daniell39842ee2020-07-10 16:42:33 -06002461 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2462 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002463 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2464 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2465 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2466 "].pViewportState->viewportCount (=%" PRIu32 ").",
2467 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002468 }
2469
Dave Houlton142c4cb2018-10-17 15:04:41 -06002470 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002471 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002472 skip |=
2473 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2474 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2475 ") must be zero or identical to pCreateInfos[%" PRIu32
2476 "].pViewportState->viewportCount (=%" PRIu32 ").",
2477 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002478 }
2479
Dave Houlton142c4cb2018-10-17 15:04:41 -06002480 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002481 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002482 skip |= LogError(
2483 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002484 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2485 "] "
2486 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2487 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2488 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002489 }
2490
Petr Krausa6103552017-11-16 21:21:58 +01002491 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002492 skip |= LogError(
2493 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002494 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2495 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002496 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2497 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002498 }
2499
2500 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002501 skip |= LogError(
2502 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002503 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2504 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002505 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2506 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002507 }
2508
Jeff Bolz3e71f782018-08-29 23:15:45 -05002509 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002510 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2511 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2512 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002513 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002514 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2515 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2516 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2517 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002518 }
2519
Jeff Bolz9af91c52018-09-01 21:53:57 -05002520 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002521 shading_rate_image_struct->viewportCount > 0 &&
2522 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002523 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002524 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002525 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002526 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2527 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002528 i, i);
2529 }
2530
Chris Mayer328d8212018-12-11 14:16:18 +01002531 if (vp_swizzle_struct) {
2532 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002533 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2534 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2535 " does "
2536 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2537 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002538 }
2539 }
2540
Petr Krausb3fcdb42018-01-09 22:09:09 +01002541 // validate the VkViewports
2542 if (!has_dynamic_viewport && viewport_state.pViewports) {
2543 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2544 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002545 const char *fn_name = "vkCreateGraphicsPipelines";
2546 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2547 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2548 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002549 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002550 }
2551 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002552
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002553 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002554 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2555 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2556 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2557 "VK_NV_clip_space_w_scaling extension is not enabled.",
2558 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002559 }
2560
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002561 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002562 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2563 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2564 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2565 "VK_EXT_discard_rectangles extension is not enabled.",
2566 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002567 }
2568
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002569 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002570 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2571 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2572 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2573 "VK_EXT_sample_locations extension is not enabled.",
2574 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002575 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002576
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002577 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002578 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2579 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2580 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2581 "VK_NV_scissor_exclusive extension is not enabled.",
2582 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002583 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002584
2585 if (coarse_sample_order_struct &&
2586 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2587 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002588 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2589 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2590 "] "
2591 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2592 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2593 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002594 }
2595
2596 if (coarse_sample_order_struct) {
2597 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002598 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002599 }
2600 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002601
2602 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2603 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002604 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2605 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2606 "] "
2607 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2608 ") "
2609 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2610 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002611 }
2612 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002613 skip |= LogError(
2614 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002615 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2616 "] "
2617 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2618 i);
2619 }
2620 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002621 }
2622
2623 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002624 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2625 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2626 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2627 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002628 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002629 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002630 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002631 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2632 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002633 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002634 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002635 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002636 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002637 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002638 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002639 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002640 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2641 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002642
2643 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002644 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002645 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002646 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002647
2648 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002649 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002650 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2651 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2652
2653 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002654 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002655 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2656 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002657 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002658 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002659
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002660 skip |= validate_flags(
2661 "vkCreateGraphicsPipelines",
2662 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2663 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002664 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002665
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002666 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002667 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002668 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2669 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2670
2671 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002672 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002673 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2674 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2675
2676 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002677 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002678 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2679 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2680 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002681 }
John Zulauf7acac592017-11-06 11:15:53 -07002682 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002683 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002684 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2685 "vkCreateGraphicsPipelines(): parameter "
2686 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2687 i);
John Zulauf7acac592017-11-06 11:15:53 -07002688 }
2689 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2690 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2691 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002692 skip |= LogError(
2693 device,
2694
Dave Houlton413a6782018-05-22 13:01:54 -06002695 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002696 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002697 }
2698 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002699
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002700 const auto *line_state =
2701 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002702
2703 if (line_state) {
2704 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2705 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2706 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2707 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002708 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2709 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2710 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2711 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002712 }
2713 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2714 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002715 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2716 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2717 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2718 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002719 }
2720 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2721 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002722 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2723 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2724 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2725 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002726 }
2727 }
2728 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2729 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2730 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002731 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2732 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2733 "range [1,256].",
2734 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002735 }
2736 }
2737 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002738 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002739 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2740 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002741 skip |=
2742 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2743 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2744 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2745 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002746 }
2747 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2748 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002749 skip |=
2750 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2751 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2752 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2753 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002754 }
2755 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2756 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002757 skip |=
2758 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2759 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2760 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2761 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002762 }
2763 if (line_state->stippledLineEnable) {
2764 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2765 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002766 skip |=
2767 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2768 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2769 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2770 "stippledRectangularLines feature.",
2771 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002772 }
2773 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2774 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002775 skip |=
2776 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2777 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2778 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2779 "stippledBresenhamLines feature.",
2780 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002781 }
2782 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2783 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002784 skip |=
2785 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2786 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2787 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2788 "stippledSmoothLines feature.",
2789 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002790 }
2791 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2792 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002793 skip |=
2794 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2795 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2796 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2797 "stippledRectangularLines and strictLines features.",
2798 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002799 }
2800 }
2801 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 }
2803
Petr Krause91f7a12017-12-14 20:57:36 +01002804 bool uses_color_attachment = false;
2805 bool uses_depthstencil_attachment = false;
2806 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002807 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002808 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2809 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002810 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002811 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002812 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002813 }
2814 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002815 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002816 }
Petr Krause91f7a12017-12-14 20:57:36 +01002817 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002818 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002819 }
2820
2821 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002823 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002824 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002825 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002826 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002827
2828 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002829 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002831 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002832
2833 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002834 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2836 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2837
2838 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002839 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002840 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2841 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2842
2843 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002844 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002845 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2846 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002847 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002848
2849 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002850 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002851 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2852 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2853
2854 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002855 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002856 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2857 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2858
2859 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002860 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002861 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2862 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002863 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002864
2865 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002866 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2868 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002869 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870
2871 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002872 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002873 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2874 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002875 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876
2877 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002878 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002879 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2880 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002881 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002882
2883 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002884 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002885 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2886 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002887 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002888
2889 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002890 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002891 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2892 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002893 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894
2895 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002896 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2898 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002899 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900
2901 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002902 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002903 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2904 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002905 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002906
2907 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002908 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002909 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2910 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2911 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002912 }
2913 }
2914
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002915 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02002916 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
2917 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002918
Petr Krause91f7a12017-12-14 20:57:36 +01002919 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002920 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2921 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2922 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2923 pCreateInfos[i].pColorBlendState,
2924 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2925 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2926
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002927 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002928 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002929 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
ziga-lunarg8de09162021-08-05 15:21:33 +02002930 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002931 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2932 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002933 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2934 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002935
2936 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002937 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002938 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002939 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940
2941 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002942 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002943 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2944 pCreateInfos[i].pColorBlendState->logicOpEnable);
2945
2946 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002947 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002948 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2949 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002950 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002951 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002952
2953 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002954 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2955 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002956 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002957 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002958 ParameterName::IndexVector{i, attachment_index}),
2959 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002960
2961 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002962 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002963 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002964 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002966 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002967 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968
2969 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002970 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002971 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002972 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002974 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002975 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002976
2977 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002978 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002979 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002980 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002981 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002982 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002983 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002984
2985 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002986 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002988 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002990 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002991 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002992
2993 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002994 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002996 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002997 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002998 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002999 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000
3001 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003002 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003004 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003005 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003006 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003007 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003008
3009 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003010 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003011 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003012 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003013 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003014 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003015 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003016
3017 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3018 bool invalid = false;
3019 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3020 case VK_BLEND_OP_ZERO_EXT:
3021 case VK_BLEND_OP_SRC_EXT:
3022 case VK_BLEND_OP_DST_EXT:
3023 case VK_BLEND_OP_SRC_OVER_EXT:
3024 case VK_BLEND_OP_DST_OVER_EXT:
3025 case VK_BLEND_OP_SRC_IN_EXT:
3026 case VK_BLEND_OP_DST_IN_EXT:
3027 case VK_BLEND_OP_SRC_OUT_EXT:
3028 case VK_BLEND_OP_DST_OUT_EXT:
3029 case VK_BLEND_OP_SRC_ATOP_EXT:
3030 case VK_BLEND_OP_DST_ATOP_EXT:
3031 case VK_BLEND_OP_XOR_EXT:
3032 case VK_BLEND_OP_INVERT_EXT:
3033 case VK_BLEND_OP_INVERT_RGB_EXT:
3034 case VK_BLEND_OP_LINEARDODGE_EXT:
3035 case VK_BLEND_OP_LINEARBURN_EXT:
3036 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3037 case VK_BLEND_OP_LINEARLIGHT_EXT:
3038 case VK_BLEND_OP_PINLIGHT_EXT:
3039 case VK_BLEND_OP_HARDMIX_EXT:
3040 case VK_BLEND_OP_PLUS_EXT:
3041 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3042 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3043 case VK_BLEND_OP_PLUS_DARKER_EXT:
3044 case VK_BLEND_OP_MINUS_EXT:
3045 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3046 case VK_BLEND_OP_CONTRAST_EXT:
3047 case VK_BLEND_OP_INVERT_OVG_EXT:
3048 case VK_BLEND_OP_RED_EXT:
3049 case VK_BLEND_OP_GREEN_EXT:
3050 case VK_BLEND_OP_BLUE_EXT:
3051 invalid = true;
3052 break;
3053 default:
3054 break;
3055 }
3056 if (invalid) {
3057 skip |= LogError(
3058 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3059 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3060 "].pColorBlendState->pAttachments[%" PRIu32
3061 "].colorBlendOp (%s) is not valid when "
3062 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3063 "VK_FALSE",
3064 i, attachment_index,
3065 string_VkBlendOp(
3066 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3067 }
3068 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003069 }
3070 }
3071
3072 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003073 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003074 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
3075 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3076 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003077 }
3078
3079 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3080 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3081 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003082 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003083 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003084 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3085 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003086 }
3087 }
3088 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003089
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003090 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3091 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003092 if (pCreateInfos[i].basePipelineIndex != -1) {
3093 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003094 skip |=
3095 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003096 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003097 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003098 "and pCreateInfos->basePipelineIndex is not -1.",
3099 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003100 }
3101 }
3102
Petr Kraus9752aae2017-11-24 03:05:50 +01003103 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3104 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003105 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003106 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003107 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003108 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3109 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003110 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003111 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003112 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003113 skip |=
3114 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
3115 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
3116 "index into the pCreateInfos array, of size %d.",
3117 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003118 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003119 }
3120 }
3121
Petr Kraus9752aae2017-11-24 03:05:50 +01003122 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003123 if (!device_extensions.vk_nv_fill_rectangle) {
3124 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3125 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003126 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3127 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3128 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3129 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003130 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3131 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003132 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003133 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003134 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
3135 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3136 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003137 }
3138 } else {
3139 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3140 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3141 (physical_device_features.fillModeNonSolid == false)) {
3142 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003143 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3144 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003145 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
3146 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3147 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003148 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003149 }
Petr Kraus299ba622017-11-24 03:09:03 +01003150
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003151 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003152 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003153 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3154 "The line width state is static (pCreateInfos[%" PRIu32
3155 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3156 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3157 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3158 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003159 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003161
3162 // Validate no flags not allowed are used
3163 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003164 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
3165 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3166 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3167 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003168 }
3169 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003170 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
3171 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3172 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3173 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003174 }
3175 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3176 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07003177 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3178 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3179 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003180 }
3181 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3182 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07003183 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3184 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3185 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003186 }
3187 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3188 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07003189 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3190 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3191 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003192 }
3193 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3194 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003195 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3196 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3197 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003198 }
3199 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3200 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003201 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3202 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3203 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003204 }
3205 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3206 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003207 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3208 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3209 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003210 }
3211 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3212 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003213 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3214 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3215 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003216 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 }
3218 }
3219
3220 return skip;
3221}
3222
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003223bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3224 uint32_t createInfoCount,
3225 const VkComputePipelineCreateInfo *pCreateInfos,
3226 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003227 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003228 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003229 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003230 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003231 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003232 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003233 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003234 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003235 skip |=
3236 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3237 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3238 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3239 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003240 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003241
3242 // Make sure compute stage is selected
3243 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003244 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3245 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3246 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003247 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003248
sfricke-samsungeb549012021-04-16 01:25:51 -07003249 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3250 // Validate no flags not allowed are used
3251 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3252 skip |= LogError(
3253 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3254 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3255 i, flags);
3256 }
3257 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3258 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3259 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3260 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3261 i, flags);
3262 }
3263 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3264 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3265 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3266 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3267 i, flags);
3268 }
3269 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3270 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3271 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3272 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3273 i, flags);
3274 }
3275 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3276 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3277 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3278 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3279 i, flags);
3280 }
3281 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3282 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3283 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3284 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3285 i, flags);
3286 }
3287 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3288 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3289 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3290 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3291 i, flags);
3292 }
3293 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3294 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3295 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3296 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3297 i, flags);
3298 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003299 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3300 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
3301 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3302 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3303 i, flags);
3304 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003305 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3306 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3307 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3308 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3309 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003310 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003311 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3312 if (pCreateInfos[i].basePipelineIndex != -1) {
3313 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3314 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3315 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3316 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3317 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3318 i);
3319 }
3320 }
3321
3322 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3323 if (pCreateInfos[i].basePipelineIndex != -1) {
3324 skip |= LogError(
3325 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3326 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3327 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3328 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3329 i);
3330 }
3331 } else {
3332 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3333 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3334 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3335 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3336 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3337 }
3338 }
3339 }
ziga-lunargc6341372021-07-28 12:57:42 +02003340
3341 std::stringstream msg;
3342 msg << "pCreateInfos[%" << i << "].stage";
3343 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003344 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003345 return skip;
3346}
3347
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003348bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003349 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003350 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003351
3352 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003353 const auto &features = physical_device_features;
3354 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003355
John Zulauf71968502017-10-26 13:51:15 -06003356 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3357 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003358 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3359 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3360 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3361 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003362 }
3363
3364 // Anistropy cannot be enabled in sampler unless enabled as a feature
3365 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003366 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3367 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3368 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003369 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003370 }
John Zulauf71968502017-10-26 13:51:15 -06003371
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003372 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3373 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003374 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3375 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3376 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3377 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003378 }
3379 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003380 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3381 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3382 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3383 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003384 }
3385 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003386 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3387 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3388 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3389 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003390 }
3391 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3392 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3393 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3394 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003395 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3396 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3397 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3398 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3399 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3400 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003401 }
3402 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003403 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3404 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3405 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003406 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003407 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003408 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3409 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3410 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003411 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003412 }
3413
3414 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3415 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003416 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3417 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003418 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003419 if (sampler_reduction != nullptr) {
3420 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3421 skip |= LogError(
3422 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3423 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3424 }
3425 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003426 }
3427
3428 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3429 // valid VkBorderColor value
3430 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3431 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3432 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003433 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3434 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003435 }
3436
John Zulauf275805c2017-10-26 15:34:49 -06003437 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003438 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003439 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3440 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003441 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3442 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3443 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003444 }
3445 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003446
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003447 // Check for valid Lod range
3448 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003449 skip |=
3450 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3451 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003452 }
3453
3454 // Check mipLodBias to device limit
3455 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003456 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3457 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3458 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003459 }
3460
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003461 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003462 if (sampler_conversion != nullptr) {
3463 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3464 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3465 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3466 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003467 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003468 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003469 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3470 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3471 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3472 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3473 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3474 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3475 }
3476 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003477
3478 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3479 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3480 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3481 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3482 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3483 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3484 }
3485 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3486 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3487 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3488 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3489 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3490 }
3491 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3492 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3493 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3494 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3495 pCreateInfo->minLod, pCreateInfo->maxLod);
3496 }
3497 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3498 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3499 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3500 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3501 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3502 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3503 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3504 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3505 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3506 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3507 }
3508 if (pCreateInfo->anisotropyEnable) {
3509 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3510 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3511 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3512 }
3513 if (pCreateInfo->compareEnable) {
3514 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3515 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3516 "pCreateInfo->compareEnable must be VK_FALSE");
3517 }
3518 if (pCreateInfo->unnormalizedCoordinates) {
3519 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3520 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3521 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3522 }
3523 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003524 }
3525
Tony-LunarG7337b312020-04-15 16:40:25 -06003526 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3527 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3528 if (!device_extensions.vk_ext_custom_border_color) {
3529 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3530 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3531 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3532 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003533 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003534 if (!custom_create_info) {
3535 skip |=
3536 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3537 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3538 "struct in pNext chain.\n",
3539 string_VkBorderColor(pCreateInfo->borderColor));
3540 } else {
3541 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3542 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3543 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3544 !FormatIsSampledFloat(custom_create_info->format)))) {
3545 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3546 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3547 "whose type does not match\n",
3548 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3549 ;
3550 }
3551 }
3552 }
3553
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003554 return skip;
3555}
3556
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003557bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3558 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3559 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003560 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003561 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003562
3563 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3564 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3565 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3566 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003567 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3568 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3569 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3570 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3571 ++descriptor_index) {
3572 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003573 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003574 "vkCreateDescriptorSetLayout: required parameter "
3575 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3576 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003577 }
3578 }
3579 }
3580
3581 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3582 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3583 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003584 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3585 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3586 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3587 "values.",
3588 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003589 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003590
3591 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3592 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3593 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3594 skip |=
3595 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3596 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3597 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3598 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3599 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3600 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003601 }
3602 }
3603 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003604 return skip;
3605}
3606
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003607bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3608 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003609 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003610 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3611 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3612 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003613 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3614 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003615}
3616
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003617bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3618 const VkWriteDescriptorSet *pDescriptorWrites,
3619 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003620 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003621
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003622 if (pDescriptorWrites != NULL) {
3623 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3624 // descriptorCount must be greater than 0
3625 if (pDescriptorWrites[i].descriptorCount == 0) {
3626 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003627 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3628 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003629 }
3630
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003631 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3632 if (validateDstSet) {
3633 // dstSet must be a valid VkDescriptorSet handle
3634 skip |= validate_required_handle(vkCallingFunction,
3635 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3636 pDescriptorWrites[i].dstSet);
3637 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003638
3639 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3640 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3641 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3642 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3643 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3644 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3645 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003646 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3647 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003648 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003649 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3650 "%s(): if pDescriptorWrites[%d].descriptorType is "
3651 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3652 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3653 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3654 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003655 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3656 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003657 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3658 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003659 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3660 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003661 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003662 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3663 ParameterName::IndexVector{i, descriptor_index}),
3664 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003665 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003666 }
3667 }
3668 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3669 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3670 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3671 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3672 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3673 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3674 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003675 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003676 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003677 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3678 "%s(): if pDescriptorWrites[%d].descriptorType is "
3679 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3680 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3681 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3682 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003683 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003684 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003685 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003686 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003687 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3688 ++descriptor_index) {
3689 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3690 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3691 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003692 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3693 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003694 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003695 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3696 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003697 }
3698 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003699 }
3700 }
3701 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3702 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003703 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003704 }
3705
3706 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3707 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003708 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003709 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3710 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003711 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003712 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003713 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3714 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3715 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003716 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003717 }
3718 }
3719 }
3720 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3721 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003722 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003723 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3724 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003725 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003726 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003727 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3728 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3729 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003730 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003731 }
3732 }
3733 }
3734 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003735 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3736 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003737 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003738 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003739 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3740 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3741 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3742 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3743 "accelerationStructureCount %d member equals descriptorCount %d.",
3744 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3745 pDescriptorWrites[i].descriptorCount);
3746 }
3747 // further checks only if we have right structtype
3748 if (pnext_struct) {
3749 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3750 skip |= LogError(
3751 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3752 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3753 ".",
3754 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003755 }
sourav parmarbcee7512020-12-28 14:34:49 -08003756 if (pnext_struct->accelerationStructureCount == 0) {
3757 skip |= LogError(device,
3758 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003759 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003760 }
3761 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003762 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003763 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3764 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3765 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3766 skip |= LogError(device,
3767 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3768 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003769 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003770 }
3771 }
3772 }
sourav parmarbcee7512020-12-28 14:34:49 -08003773 }
3774 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003775 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003776 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3777 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3778 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3779 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3780 "accelerationStructureCount %d member equals descriptorCount %d.",
3781 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3782 pDescriptorWrites[i].descriptorCount);
3783 }
3784 // further checks only if we have right structtype
3785 if (pnext_struct) {
3786 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3787 skip |= LogError(
3788 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3789 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3790 ".",
3791 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003792 }
sourav parmarbcee7512020-12-28 14:34:49 -08003793 if (pnext_struct->accelerationStructureCount == 0) {
3794 skip |= LogError(device,
3795 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003796 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003797 }
3798 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003799 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003800 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3801 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3802 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3803 skip |= LogError(device,
3804 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3805 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003806 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003807 }
3808 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003809 }
3810 }
3811 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003812 }
3813 }
3814 return skip;
3815}
3816
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003817bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3818 const VkWriteDescriptorSet *pDescriptorWrites,
3819 uint32_t descriptorCopyCount,
3820 const VkCopyDescriptorSet *pDescriptorCopies) const {
3821 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3822}
3823
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003824bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003825 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003826 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003827 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3828}
3829
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003830bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3831 const VkAllocationCallbacks *pAllocator,
3832 VkRenderPass *pRenderPass) const {
3833 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3834}
3835
Mike Schuchardt2df08912020-12-15 16:28:09 -08003836bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003837 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003838 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003839 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3840}
3841
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003842bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3843 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003844 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003845 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003846
3847 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3848 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3849 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003850 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3851 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003852 return skip;
3853}
3854
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003855bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003856 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003857 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003858
3859 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3860 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003861 bool cb_is_secondary;
3862 {
3863 auto lock = cb_read_lock();
3864 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3865 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003866
Tony-LunarG3c287f62020-12-17 12:39:49 -07003867 if (cb_is_secondary) {
3868 // Implicit VUs
3869 // validate only sType here; pointer has to be validated in core_validation
3870 const bool k_not_required = false;
3871 const char *k_no_vuid = nullptr;
3872 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3873 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003874 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3875 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003876
Tony-LunarG3c287f62020-12-17 12:39:49 -07003877 if (info) {
3878 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003879 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3880 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003881 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003882 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3883 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3884 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3885 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003886
Tony-LunarG3c287f62020-12-17 12:39:49 -07003887 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003888
Tony-LunarG3c287f62020-12-17 12:39:49 -07003889 // Explicit VUs
3890 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003891 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003892 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3893 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3894 cmd_name);
3895 }
3896
3897 if (physical_device_features.inheritedQueries) {
3898 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003899 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3900 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3901 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003902 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003903 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003904 }
3905
3906 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003907 skip |=
3908 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3909 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3910 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3911 } else { // !pipelineStatisticsQuery
3912 skip |=
3913 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3914 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003915 }
3916
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003917 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003918 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003919 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003920 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3921 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3922 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003923 commandBuffer,
3924 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003925 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3926 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3927 }
Petr Kraus139757b2019-08-15 17:19:33 +02003928 }
ziga-lunarg9d019132021-07-19 01:05:31 +02003929
3930 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
3931 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
3932 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
3933 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
3934 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
3935 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
3936 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
3937 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
3938 }
Petr Kraus139757b2019-08-15 17:19:33 +02003939 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003940 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003941 return skip;
3942}
3943
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003944bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003945 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003946 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003947
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003948 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003949 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003950 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3951 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3952 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003953 }
3954 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003955 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3956 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3957 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003958 }
3959 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003960 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003961 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003962 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3963 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3964 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3965 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003966 }
3967 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003968
3969 if (pViewports) {
3970 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3971 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003972 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003973 skip |= manual_PreCallValidateViewport(
3974 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003975 }
3976 }
3977
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003978 return skip;
3979}
3980
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003981bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003982 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003983 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003984
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003985 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003986 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003987 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3988 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3989 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003990 }
3991 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003992 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3993 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3994 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003995 }
3996 } else { // multiViewport enabled
3997 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003998 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003999 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4000 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4001 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4002 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004003 }
4004 }
4005
Petr Kraus6260f0a2018-02-27 21:15:55 +01004006 if (pScissors) {
4007 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4008 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004009
Petr Kraus6260f0a2018-02-27 21:15:55 +01004010 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004011 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4012 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4013 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004014 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004015
Petr Kraus6260f0a2018-02-27 21:15:55 +01004016 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004017 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4018 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4019 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004020 }
4021
4022 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4023 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004024 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4025 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4026 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4027 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004028 }
4029
4030 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4031 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004032 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4033 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4034 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4035 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004036 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004037 }
4038 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004039
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004040 return skip;
4041}
4042
Jeff Bolz5c801d12019-10-09 10:38:45 -05004043bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004044 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004045
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004046 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004047 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4048 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004049 }
4050
4051 return skip;
4052}
4053
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004054bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004055 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004056 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004057
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004058 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004059 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004060 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
4061 }
4062 if (drawCount > device_limits.maxDrawIndirectCount) {
4063 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004064 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
4065 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004066 }
4067 return skip;
4068}
4069
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004070bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004071 VkDeviceSize offset, uint32_t drawCount,
4072 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004073 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004074 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004075 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4076 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
4077 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004078 }
4079 if (drawCount > device_limits.maxDrawIndirectCount) {
4080 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004081 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4082 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004083 }
4084 return skip;
4085}
4086
sfricke-samsungf692b972020-05-02 08:00:45 -07004087bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4088 VkDeviceSize countBufferOffset, bool khr) const {
4089 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004090 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004091 if (offset & 3) {
4092 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004093 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004094 }
4095
4096 if (countBufferOffset & 3) {
4097 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004098 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004099 countBufferOffset);
4100 }
4101 return skip;
4102}
4103
4104bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4105 VkDeviceSize offset, VkBuffer countBuffer,
4106 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4107 uint32_t stride) const {
4108 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4109}
4110
4111bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4112 VkDeviceSize offset, VkBuffer countBuffer,
4113 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4114 uint32_t stride) const {
4115 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4116}
4117
4118bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4119 VkDeviceSize countBufferOffset, bool khr) const {
4120 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004121 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004122 if (offset & 3) {
4123 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004124 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004125 }
4126
4127 if (countBufferOffset & 3) {
4128 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004129 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004130 countBufferOffset);
4131 }
4132 return skip;
4133}
4134
4135bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4136 VkDeviceSize offset, VkBuffer countBuffer,
4137 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4138 uint32_t stride) const {
4139 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4140}
4141
4142bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4143 VkDeviceSize offset, VkBuffer countBuffer,
4144 VkDeviceSize countBufferOffset,
4145 uint32_t maxDrawCount, uint32_t stride) const {
4146 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4147}
4148
Tony-LunarG4490de42021-06-21 15:49:19 -06004149bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4150 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4151 uint32_t firstInstance, uint32_t stride) const {
4152 bool skip = false;
4153 if (stride & 3) {
4154 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4155 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4156 }
4157 if (drawCount && nullptr == pVertexInfo) {
4158 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4159 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4160 "one or more valid instances of VkMultiDrawInfoEXT structures");
4161 }
4162 return skip;
4163}
4164
4165bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4166 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4167 uint32_t instanceCount, uint32_t firstInstance,
4168 uint32_t stride, const int32_t *pVertexOffset) const {
4169 bool skip = false;
4170 if (stride & 3) {
4171 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4172 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4173 }
4174 if (drawCount && nullptr == pIndexInfo) {
4175 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4176 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4177 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4178 }
4179 return skip;
4180}
4181
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004182bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4183 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004184 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004185 bool skip = false;
4186 for (uint32_t rect = 0; rect < rectCount; rect++) {
4187 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004188 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
4189 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004190 }
sfricke-samsung10867682020-04-25 02:20:39 -07004191 if (pRects[rect].rect.extent.width == 0) {
4192 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
4193 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
4194 }
4195 if (pRects[rect].rect.extent.height == 0) {
4196 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
4197 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
4198 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004199 }
4200 return skip;
4201}
4202
Andrew Fobel3abeb992020-01-20 16:33:22 -05004203bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4204 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4205 VkImageFormatProperties2 *pImageFormatProperties,
4206 const char *apiName) const {
4207 bool skip = false;
4208
4209 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004210 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004211 if (image_stencil_struct != nullptr) {
4212 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4213 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4214 // No flags other than the legal attachment bits may be set
4215 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4216 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004217 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4218 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4219 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4220 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4221 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004222 }
4223 }
4224 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004225 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4226 if (image_drm_format) {
4227 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4228 skip |= LogError(
4229 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4230 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4231 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4232 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4233 }
4234 } else {
4235 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4236 skip |= LogError(
4237 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4238 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4239 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4240 apiName);
4241 }
4242 }
4243 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4244 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4245 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4246 if (!format_list || format_list->viewFormatCount == 0) {
4247 skip |= LogError(
4248 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4249 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4250 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4251 apiName);
4252 }
4253 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004254 }
4255
4256 return skip;
4257}
4258
4259bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4260 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4261 VkImageFormatProperties2 *pImageFormatProperties) const {
4262 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4263 "vkGetPhysicalDeviceImageFormatProperties2");
4264}
4265
4266bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4267 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4268 VkImageFormatProperties2 *pImageFormatProperties) const {
4269 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4270 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4271}
4272
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004273bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4274 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4275 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4276 bool skip = false;
4277
4278 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4279 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4280 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4281 }
4282
4283 return skip;
4284}
4285
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004286bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4287 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4288 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4289 bool skip = false;
4290
4291 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4292 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4293 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4294 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4295 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4296 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4297 }
4298
ziga-lunarg42f884b2021-08-25 16:13:20 +02004299 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004300}
4301
sfricke-samsung3999ef62020-02-09 17:05:59 -08004302bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4303 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4304 bool skip = false;
4305
4306 if (pRegions != nullptr) {
4307 for (uint32_t i = 0; i < regionCount; i++) {
4308 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004309 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4310 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004311 }
4312 }
4313 }
4314 return skip;
4315}
4316
Jeff Leger178b1e52020-10-05 12:22:23 -04004317bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4318 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4319 bool skip = false;
4320
4321 if (pCopyBufferInfo->pRegions != nullptr) {
4322 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4323 if (pCopyBufferInfo->pRegions[i].size == 0) {
4324 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4325 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4326 }
4327 }
4328 }
4329 return skip;
4330}
4331
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004332bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004333 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4334 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004335 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004336
4337 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004338 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4339 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4340 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004341 }
4342
4343 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004344 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4345 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4346 "), must be greater than zero and less than or equal to 65536.",
4347 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004348 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004349 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4350 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4351 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004352 }
4353 return skip;
4354}
4355
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004356bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004357 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004358 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004359
4360 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004361 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4362 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4363 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004364 }
4365
4366 if (size != VK_WHOLE_SIZE) {
4367 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004368 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004369 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4370 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004371 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004372 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4373 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004374 }
4375 }
4376 return skip;
4377}
4378
sfricke-samsunga1d00272021-03-10 21:37:41 -08004379bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004380 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004381
4382 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004383 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4384 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4385 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4386 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004387 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004388 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4389 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4390 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004391 }
4392
4393 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4394 // queueFamilyIndexCount uint32_t values
4395 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004396 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004397 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004398 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004399 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4400 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004401 }
4402 }
4403
Dave Houlton413a6782018-05-22 13:01:54 -06004404 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004405 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004406
sfricke-samsunga1d00272021-03-10 21:37:41 -08004407 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4408 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4409 if (format_list_info) {
4410 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4411 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4412 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4413 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4414 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4415 func_name, viewFormatCount);
4416 }
4417
4418 // Using the first format, compare the rest of the formats against it that they are compatible
4419 for (uint32_t i = 1; i < viewFormatCount; i++) {
4420 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4421 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4422 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4423 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4424 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4425 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4426 string_VkFormat(format_list_info->pViewFormats[i]));
4427 }
4428 }
4429 }
4430
4431 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4432 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4433 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4434 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4435 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4436 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4437 func_name);
4438 } else {
4439 if (format_list_info == nullptr) {
4440 skip |= LogError(
4441 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4442 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4443 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4444 func_name);
4445 } else if (format_list_info->viewFormatCount == 0) {
4446 skip |= LogError(
4447 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4448 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4449 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4450 func_name);
4451 } else {
4452 bool found_base_format = false;
4453 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4454 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4455 found_base_format = true;
4456 break;
4457 }
4458 }
4459 if (!found_base_format) {
4460 skip |=
4461 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4462 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4463 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4464 "pCreateInfo->imageFormat.",
4465 func_name);
4466 }
4467 }
4468 }
4469 }
4470 }
4471 return skip;
4472}
4473
4474bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4475 const VkAllocationCallbacks *pAllocator,
4476 VkSwapchainKHR *pSwapchain) const {
4477 bool skip = false;
4478 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4479 return skip;
4480}
4481
4482bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4483 const VkSwapchainCreateInfoKHR *pCreateInfos,
4484 const VkAllocationCallbacks *pAllocator,
4485 VkSwapchainKHR *pSwapchains) const {
4486 bool skip = false;
4487 if (pCreateInfos) {
4488 for (uint32_t i = 0; i < swapchainCount; i++) {
4489 std::stringstream func_name;
4490 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4491 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4492 }
4493 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004494 return skip;
4495}
4496
Jeff Bolz5c801d12019-10-09 10:38:45 -05004497bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004498 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004499
4500 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004501 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004502 if (present_regions) {
4503 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004504 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004505 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4506 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004507 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004508 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4509 "extension swapchainCount is %i. These values must be equal.",
4510 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004511 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004512 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004513 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4514 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004515 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4516 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4517 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004518 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004519 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004520 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004521 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004522 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004523 }
4524 }
4525
4526 return skip;
4527}
4528
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004529bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4530 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4531 const VkAllocationCallbacks *pAllocator,
4532 VkDisplayModeKHR *pMode) const {
4533 bool skip = false;
4534
4535 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4536 if (display_mode_parameters.visibleRegion.width == 0) {
4537 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4538 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4539 }
4540 if (display_mode_parameters.visibleRegion.height == 0) {
4541 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4542 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4543 }
4544 if (display_mode_parameters.refreshRate == 0) {
4545 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4546 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4547 }
4548
4549 return skip;
4550}
4551
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004552#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004553bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4554 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4555 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004556 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004557 bool skip = false;
4558
4559 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004560 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4561 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004562 }
4563
4564 return skip;
4565}
4566#endif // VK_USE_PLATFORM_WIN32_KHR
4567
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004568bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004569 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004570 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004571 bool skip = false;
4572
4573 if (pCreateInfo) {
4574 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004575 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4576 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004577 }
4578
4579 if (pCreateInfo->pPoolSizes) {
4580 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4581 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004582 skip |= LogError(
4583 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004584 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004585 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004586 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4587 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004588 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4589 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4590 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4591 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4592 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004593 }
Petr Krausc8655be2017-09-27 18:56:51 +02004594 }
4595 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004596
4597 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4598 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4599 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4600 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4601 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4602 }
Petr Krausc8655be2017-09-27 18:56:51 +02004603 }
4604
4605 return skip;
4606}
4607
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004608bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004609 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004610 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004611
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004612 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004613 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004614 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4615 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4616 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004617 }
4618
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004619 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004620 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004621 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4622 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4623 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004624 }
4625
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004626 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004627 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004628 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4629 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4630 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004631 }
4632
4633 return skip;
4634}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004635
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004636bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004637 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004638 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004639
4640 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004641 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4642 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004643 }
4644 return skip;
4645}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004646
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004647bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4648 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004649 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004650 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004651
4652 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004653 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004654 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004655 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4656 "vkCmdDispatch(): baseGroupX (%" PRIu32
4657 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4658 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004659 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004660 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4661 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4662 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4663 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004664 }
4665
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004666 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004667 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004668 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4669 "vkCmdDispatch(): baseGroupY (%" PRIu32
4670 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4671 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004672 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004673 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4674 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4675 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4676 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004677 }
4678
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004679 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004680 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004681 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4682 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4683 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4684 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004685 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004686 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4687 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4688 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4689 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004690 }
4691
4692 return skip;
4693}
4694
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004695bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4696 VkPipelineBindPoint pipelineBindPoint,
4697 VkPipelineLayout layout, uint32_t set,
4698 uint32_t descriptorWriteCount,
4699 const VkWriteDescriptorSet *pDescriptorWrites) const {
4700 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4701}
4702
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004703bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4704 uint32_t firstExclusiveScissor,
4705 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004706 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004707 bool skip = false;
4708
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004709 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004710 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004711 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004712 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4713 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4714 ") is not 0.",
4715 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004716 }
4717 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004718 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004719 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4720 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4721 ") is not 1.",
4722 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004723 }
4724 } else { // multiViewport enabled
4725 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004726 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004727 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4728 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4729 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4730 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004731 }
4732 }
4733
Jeff Bolz3e71f782018-08-29 23:15:45 -05004734 if (pExclusiveScissors) {
4735 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4736 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4737
4738 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004739 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4740 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4741 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004742 }
4743
4744 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004745 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4746 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4747 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004748 }
4749
4750 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4751 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004752 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4753 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4754 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4755 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004756 }
4757
4758 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4759 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004760 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4761 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4762 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4763 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004764 }
4765 }
4766 }
4767
4768 return skip;
4769}
4770
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004771bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4772 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004773 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004774 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004775 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4776 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4777 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4778 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4779 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4780 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004781 }
4782
4783 return skip;
4784}
4785
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004786bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4787 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004788 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004789 bool skip = false;
4790
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004791 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004792 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004793 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004794 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4795 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4796 ") is not 0.",
4797 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004798 }
4799 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004800 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004801 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4802 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4803 ") is not 1.",
4804 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004805 }
4806 }
4807
Jeff Bolz9af91c52018-09-01 21:53:57 -05004808 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004809 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004810 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4811 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4812 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4813 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004814 }
4815
4816 return skip;
4817}
4818
Jeff Bolz5c801d12019-10-09 10:38:45 -05004819bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4820 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4821 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004822 bool skip = false;
4823
Dave Houlton142c4cb2018-10-17 15:04:41 -06004824 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004825 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4826 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4827 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004828 }
4829
4830 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004831 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004832 }
4833
4834 return skip;
4835}
4836
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004837bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004838 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004839 bool skip = false;
4840
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004841 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004842 skip |= LogError(
4843 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004844 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4845 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004846 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004847 }
4848
4849 return skip;
4850}
4851
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004852bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4853 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004854 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004855 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004856 static const int condition_multiples = 0b0011;
4857 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004858 skip |= LogError(
4859 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004860 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004861 }
Lockee1c22882019-06-10 16:02:54 -06004862 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004863 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4864 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4865 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4866 stride);
Lockee1c22882019-06-10 16:02:54 -06004867 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004868 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004869 skip |= LogError(
4870 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4871 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004872 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004873 if (drawCount > device_limits.maxDrawIndirectCount) {
4874 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004875 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4876 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004877 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004878 return skip;
4879}
4880
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004881bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4882 VkDeviceSize offset, VkBuffer countBuffer,
4883 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004884 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004885 bool skip = false;
4886
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004887 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004888 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4889 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4890 "), is not a multiple of 4.",
4891 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004892 }
4893
4894 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004895 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4896 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4897 "), is not a multiple of 4.",
4898 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004899 }
4900
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004901 return skip;
4902}
4903
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004904bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004905 const VkAllocationCallbacks *pAllocator,
4906 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004907 bool skip = false;
4908
4909 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4910 if (pCreateInfo != nullptr) {
4911 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4912 // VkQueryPipelineStatisticFlagBits values
4913 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4914 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004915 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4916 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4917 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4918 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004919 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004920 if (pCreateInfo->queryCount == 0) {
4921 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4922 "vkCreateQueryPool(): queryCount must be greater than zero.");
4923 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004924 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004925 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004926}
4927
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004928bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4929 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004930 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004931 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4932 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004933}
4934
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004935void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004936 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4937 VkResult result) {
4938 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004939 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004940}
4941
Mike Schuchardt2df08912020-12-15 16:28:09 -08004942void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004943 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4944 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004945 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004946 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004947 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004948}
4949
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004950void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4951 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004952 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004953 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004954 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004955}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004956
Tony-LunarG3c287f62020-12-17 12:39:49 -07004957void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004958 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004959 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4960 auto lock = cb_write_lock();
4961 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004962 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004963 }
4964 }
4965}
4966
4967void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004968 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004969 auto lock = cb_write_lock();
4970 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4971 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4972 }
4973}
4974
4975void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004976 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004977 auto lock = cb_write_lock();
4978 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4979 if (item->second == commandPool) {
4980 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004981 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004982 ++item;
4983 }
4984 }
4985}
4986
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004987bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004988 const VkAllocationCallbacks *pAllocator,
4989 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004990 bool skip = false;
4991
4992 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004993 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004994 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004995 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4996 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004997 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004998
4999 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005000 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005001 if (flags_info) {
5002 flags = flags_info->flags;
5003 }
5004
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005005 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005006 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005007 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005008 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5009 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005010 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005011 }
5012
5013#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005014 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005015#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005016 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5017 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005018#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005019 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005020#endif
5021
5022 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005023 skip |= LogError(
5024 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005025 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5026 }
5027 if (
5028#ifdef VK_USE_PLATFORM_WIN32_KHR
5029 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5030#endif
5031 (import_memory_fd && import_memory_fd->handleType) ||
5032#ifdef VK_USE_PLATFORM_ANDROID_KHR
5033 (import_memory_ahb && import_memory_ahb->buffer) ||
5034#endif
5035 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005036 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5037 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005038 }
5039 }
5040
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005041 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5042 if (export_memory) {
5043 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5044 if (export_memory_nv) {
5045 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5046 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5047 "VkExportMemoryAllocateInfoNV");
5048 }
5049#ifdef VK_USE_PLATFORM_WIN32_KHR
5050 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5051 if (export_memory_win32_nv) {
5052 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5053 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5054 "VkExportMemoryWin32HandleInfoNV");
5055 }
5056#endif
5057 }
5058
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005059 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005060 VkBool32 capture_replay = false;
5061 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005062 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005063 if (vulkan_12_features) {
5064 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5065 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5066 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005067 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005068 if (bda_features) {
5069 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5070 buffer_device_address = bda_features->bufferDeviceAddress;
5071 }
5072 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005073 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005074 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005075 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005076 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005077 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005078 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005079 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005080 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005081 }
5082 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005083 }
5084 return skip;
5085}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005086
Jason Macnak192fa0e2019-07-26 15:07:16 -07005087bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005088 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005089 bool skip = false;
5090
5091 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5092 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5093 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005094 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005095 } else {
5096 uint32_t vertex_component_size = 0;
5097 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5098 vertex_component_size = 4;
5099 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5100 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5101 vertex_component_size = 2;
5102 }
5103 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005104 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005105 }
5106 }
5107
5108 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5109 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005110 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005111 } else {
5112 uint32_t index_element_size = 0;
5113 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5114 index_element_size = 4;
5115 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5116 index_element_size = 2;
5117 }
5118 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005119 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005120 }
5121 }
5122 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5123 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005124 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005125 }
5126 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005127 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005128 }
5129 }
5130
5131 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005132 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005133 }
5134
5135 return skip;
5136}
5137
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005138bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5139 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005140 bool skip = false;
5141
5142 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005143 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005144 }
5145 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005146 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005147 }
5148
5149 return skip;
5150}
5151
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005152bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5153 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005154 bool skip = false;
5155 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005156 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005157 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005158 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005159 }
5160 return skip;
5161}
5162
5163bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005164 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005165 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005166 bool skip = false;
5167 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005168 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5169 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5170 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005171 }
5172 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005173 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5174 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5175 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005176 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005177 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5178 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5179 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5180 }
Jason Macnak5c954952019-07-09 15:46:12 -07005181 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5182 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005183 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5184 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5185 "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 -07005186 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005187 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005188 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005189 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5190 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005191 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5192 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005193 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005194 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005195 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5196 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5197 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005198 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005199 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005200 uint64_t total_triangle_count = 0;
5201 for (uint32_t i = 0; i < info.geometryCount; i++) {
5202 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005203
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005204 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005205
Jason Macnak5c954952019-07-09 15:46:12 -07005206 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5207 continue;
5208 }
5209 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5210 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005211 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005212 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5213 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5214 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005215 }
5216 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005217 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5218 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5219 for (uint32_t i = 1; i < info.geometryCount; i++) {
5220 const VkGeometryNV &geometry = info.pGeometries[i];
5221 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005222 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005223 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
5224 "info.pGeometries[0].geometryType.",
5225 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005226 }
5227 }
5228 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005229 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5230 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5231 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5232 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5233 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5234 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5235 }
5236 }
5237 skip |=
5238 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005239 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005240 return skip;
5241}
5242
Ricardo Garciaa4935972019-02-21 17:43:18 +01005243bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5244 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005245 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005246 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005247 if (pCreateInfo) {
5248 if ((pCreateInfo->compactedSize != 0) &&
5249 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005250 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5251 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5252 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5253 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005254 }
Jason Macnak5c954952019-07-09 15:46:12 -07005255
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005256 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005257 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005258 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005259 return skip;
5260}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005261
Jeff Bolz5c801d12019-10-09 10:38:45 -05005262bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5263 const VkAccelerationStructureInfoNV *pInfo,
5264 VkBuffer instanceData, VkDeviceSize instanceOffset,
5265 VkBool32 update, VkAccelerationStructureNV dst,
5266 VkAccelerationStructureNV src, VkBuffer scratch,
5267 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005268 bool skip = false;
5269
5270 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005271 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005272 }
5273
5274 return skip;
5275}
5276
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005277bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5278 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5279 VkAccelerationStructureKHR *pAccelerationStructure) const {
5280 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005281 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005282 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005283 if (!acceleration_structure_features ||
5284 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5285 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5286 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5287 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005288 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005289 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5290 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005291 (acceleration_structure_features &&
5292 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005293 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005294 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5295 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5296 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5297 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005298 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005299 if (pCreateInfo->deviceAddress &&
5300 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5301 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5302 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5303 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5304 }
5305 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5306 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005307 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005308 }
sourav parmar83c31b12020-05-06 12:30:54 -07005309 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005310 return skip;
5311}
5312
Jason Macnak5c954952019-07-09 15:46:12 -07005313bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5314 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005315 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005316 bool skip = false;
5317 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005318 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5319 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005320 }
5321 return skip;
5322}
5323
sourav parmarcd5fb182020-07-17 12:58:44 -07005324bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5325 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5326 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5327 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005328 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005329 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005330 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005331 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005332 }
5333 return skip;
5334}
5335
Peter Chen85366392019-05-14 15:20:11 -04005336bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5337 uint32_t createInfoCount,
5338 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5339 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005340 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005341 bool skip = false;
5342
5343 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005344 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5345 std::stringstream msg;
5346 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5347 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5348 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005349 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005350 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005351 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005352 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5353 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5354 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5355 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005356 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005357
5358 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005359 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005360 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5361 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5362 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5363 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5364 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5365 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5366 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5367 }
5368 }
5369
sourav parmarf4a78252020-04-10 13:04:21 -07005370 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5371 skip |=
5372 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5373 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5374 }
5375 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5376 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5377 skip |=
5378 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5379 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5380 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5381 }
5382 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5383 if (pCreateInfos[i].basePipelineIndex != -1) {
5384 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5385 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5386 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5387 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5388 "and pCreateInfos->basePipelineIndex is not -1.");
5389 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005390 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005391 skip |=
5392 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5393 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5394 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5395 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5396 "that element.");
5397 }
sourav parmarf4a78252020-04-10 13:04:21 -07005398 }
5399 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005400 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005401 skip |=
5402 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5403 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5404 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5405 "commands pCreateInfos parameter.");
5406 }
5407 } else {
5408 if (pCreateInfos[i].basePipelineIndex != -1) {
5409 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5410 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5411 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5412 }
5413 }
5414 }
5415 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5416 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5417 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5418 }
5419 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5420 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5421 "vkCreateRayTracingPipelinesNV: flags must not include "
5422 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5423 }
5424 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5425 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5426 "vkCreateRayTracingPipelinesNV: flags must not include "
5427 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5428 }
5429 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5430 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5431 "vkCreateRayTracingPipelinesNV: flags must not include "
5432 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5433 }
5434 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5435 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5436 "vkCreateRayTracingPipelinesNV: flags must not include "
5437 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5438 }
5439 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5440 skip |= LogError(
5441 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5442 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5443 }
5444 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5445 skip |= LogError(
5446 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5447 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5448 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005449 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5450 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5451 "vkCreateRayTracingPipelinesNV: flags must not include "
5452 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5453 }
5454 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5455 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5456 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5457 }
Peter Chen85366392019-05-14 15:20:11 -04005458 }
5459
5460 return skip;
5461}
5462
sourav parmarcd5fb182020-07-17 12:58:44 -07005463bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5464 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5465 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005466 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005467 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005468 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5469 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5470 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005471 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005472 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005473 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5474 std::stringstream msg;
5475 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5476 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5477 &pCreateInfos[i].pStages[i]);
5478 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005479 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5480 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5481 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5482 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5483 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5484 }
5485 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5486 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5487 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5488 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5489 }
5490 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005491 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005492 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5493 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005494 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5495 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5496 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005497 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5498 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5499 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005500 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005501 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005502 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5503 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5504 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5505 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005506 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005507 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5508 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5509 }
5510 }
sourav parmarf4a78252020-04-10 13:04:21 -07005511 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005512 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5513 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005514 }
5515 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005516 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005517 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005518 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5519 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005520 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005521 }
5522 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5523 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5524 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005525 }
5526 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5527 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5528 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5529 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5530 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5531 skip |= LogError(
5532 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005533 "vkCreateRayTracingPipelinesKHR: If flags includes "
5534 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005535 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5536 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5537 "must not be VK_SHADER_UNUSED_KHR");
5538 }
5539 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5540 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5541 skip |= LogError(
5542 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005543 "vkCreateRayTracingPipelinesKHR: If flags includes "
5544 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005545 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5546 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5547 "element must not be VK_SHADER_UNUSED_KHR");
5548 }
5549 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005550 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5551 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5552 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5553 skip |= LogError(
5554 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5555 "vkCreateRayTracingPipelinesKHR: If "
5556 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5557 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5558 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5559 }
5560 }
sourav parmarf4a78252020-04-10 13:04:21 -07005561 }
5562 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5563 if (pCreateInfos[i].basePipelineIndex != -1) {
5564 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5565 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005566 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005567 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5568 "and pCreateInfos->basePipelineIndex is not -1.");
5569 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005570 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005571 skip |=
5572 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5573 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5574 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5575 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5576 "element.");
5577 }
sourav parmarf4a78252020-04-10 13:04:21 -07005578 }
5579 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005580 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005581 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005582 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005583 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5584 "commands pCreateInfos parameter %d.",
5585 pCreateInfos[i].basePipelineIndex, createInfoCount);
5586 }
5587 } else {
5588 if (pCreateInfos[i].basePipelineIndex != -1) {
5589 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005590 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005591 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5592 }
5593 }
5594 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005595 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5596 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5597 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5598 "vkCreateRayTracingPipelinesKHR: If flags includes "
5599 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5600 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005601 }
5602 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5603 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5604 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5605 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5606 "pLibraryInfo and pLibraryInterface must be NULL.");
5607 }
5608 if (pCreateInfos[i].pLibraryInfo) {
5609 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5610 if (pCreateInfos[i].stageCount == 0) {
5611 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5612 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5613 "stageCount must not be 0.");
5614 }
5615 if (pCreateInfos[i].groupCount == 0) {
5616 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5617 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5618 "groupCount must not be 0.");
5619 }
5620 } else {
5621 if (pCreateInfos[i].pLibraryInterface == NULL) {
5622 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5623 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5624 "is greater than 0, its "
5625 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005626 }
5627 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005628 }
5629 if (pCreateInfos[i].pLibraryInterface) {
5630 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5631 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5632 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5633 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5634 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5635 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005636 }
5637 if (deferredOperation != VK_NULL_HANDLE) {
5638 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5639 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5640 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5641 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005642 }
5643 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005644 }
5645
5646 return skip;
5647}
5648
Mike Schuchardt21638df2019-03-16 10:52:02 -07005649#ifdef VK_USE_PLATFORM_WIN32_KHR
5650bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5651 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005652 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005653 bool skip = false;
5654 if (!device_extensions.vk_khr_swapchain)
5655 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005656 if (!device_extensions.vk_khr_get_surface_capabilities2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005657 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5658 if (!device_extensions.vk_khr_surface)
5659 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005660 if (!device_extensions.vk_khr_get_physical_device_properties2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005661 skip |=
5662 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5663 if (!device_extensions.vk_ext_full_screen_exclusive)
5664 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5665 skip |= validate_struct_type(
5666 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5667 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5668 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5669 if (pSurfaceInfo != NULL) {
5670 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5671 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5672 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5673
5674 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5675 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5676 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5677 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005678 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5679 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005680
5681 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5682 }
5683 return skip;
5684}
5685#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005686
5687bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5688 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005689 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005690 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5691 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005692 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005693 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5694 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5695 }
5696 return skip;
5697}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005698
5699bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005700 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005701 bool skip = false;
5702
5703 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005704 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5705 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005706 }
5707
5708 return skip;
5709}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005710
5711bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005712 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005713 bool skip = false;
5714
5715 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005716 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5717 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005718 }
5719
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005720 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005721 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005722 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5723 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005724 }
5725
5726 return skip;
5727}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005728
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005729bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5730 uint32_t bindingCount, const VkBuffer *pBuffers,
5731 const VkDeviceSize *pOffsets) const {
5732 bool skip = false;
5733 if (firstBinding > device_limits.maxVertexInputBindings) {
5734 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5735 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5736 device_limits.maxVertexInputBindings);
5737 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5738 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5739 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5740 "maxVertexInputBindings (%u)",
5741 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5742 }
5743
Jeff Bolz165818a2020-05-08 11:19:03 -05005744 for (uint32_t i = 0; i < bindingCount; ++i) {
5745 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005746 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005747 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5748 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5749 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5750 } else {
5751 if (pOffsets[i] != 0) {
5752 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5753 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5754 }
5755 }
5756 }
5757 }
5758
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005759 return skip;
5760}
5761
Mark Lobodzinski84988402019-09-11 15:27:30 -06005762bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005763 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005764 bool skip = false;
5765 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005766 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5767 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005768 }
5769 return skip;
5770}
5771
5772bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005773 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005774 bool skip = false;
5775 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005776 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5777 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005778 }
5779 return skip;
5780}
Petr Kraus3d720392019-11-13 02:52:39 +01005781
5782bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5783 VkSemaphore semaphore, VkFence fence,
5784 uint32_t *pImageIndex) const {
5785 bool skip = false;
5786
5787 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005788 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5789 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005790 }
5791
5792 return skip;
5793}
5794
5795bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5796 uint32_t *pImageIndex) const {
5797 bool skip = false;
5798
5799 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005800 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5801 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005802 }
5803
5804 return skip;
5805}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005806
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005807bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5808 uint32_t firstBinding, uint32_t bindingCount,
5809 const VkBuffer *pBuffers,
5810 const VkDeviceSize *pOffsets,
5811 const VkDeviceSize *pSizes) const {
5812 bool skip = false;
5813
5814 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5815 for (uint32_t i = 0; i < bindingCount; ++i) {
5816 if (pOffsets[i] & 3) {
5817 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5818 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5819 }
5820 }
5821
5822 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5823 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5824 "%s: The firstBinding(%" PRIu32
5825 ") index is greater than or equal to "
5826 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5827 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5828 }
5829
5830 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5831 skip |=
5832 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5833 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5834 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5835 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5836 }
5837
5838 for (uint32_t i = 0; i < bindingCount; ++i) {
5839 // pSizes is optional and may be nullptr.
5840 if (pSizes != nullptr) {
5841 if (pSizes[i] != VK_WHOLE_SIZE &&
5842 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5843 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5844 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5845 ") is not VK_WHOLE_SIZE and is greater than "
5846 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5847 cmd_name, i, pSizes[i]);
5848 }
5849 }
5850 }
5851
5852 return skip;
5853}
5854
5855bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5856 uint32_t firstCounterBuffer,
5857 uint32_t counterBufferCount,
5858 const VkBuffer *pCounterBuffers,
5859 const VkDeviceSize *pCounterBufferOffsets) const {
5860 bool skip = false;
5861
5862 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5863 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5864 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5865 "%s: The firstCounterBuffer(%" PRIu32
5866 ") index is greater than or equal to "
5867 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5868 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5869 }
5870
5871 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5872 skip |=
5873 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5874 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5875 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5876 cmd_name, firstCounterBuffer, counterBufferCount,
5877 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5878 }
5879
5880 return skip;
5881}
5882
5883bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5884 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5885 const VkBuffer *pCounterBuffers,
5886 const VkDeviceSize *pCounterBufferOffsets) const {
5887 bool skip = false;
5888
5889 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5890 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5891 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5892 "%s: The firstCounterBuffer(%" PRIu32
5893 ") index is greater than or equal to "
5894 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5895 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5896 }
5897
5898 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5899 skip |=
5900 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5901 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5902 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5903 cmd_name, firstCounterBuffer, counterBufferCount,
5904 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5905 }
5906
5907 return skip;
5908}
5909
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005910bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5911 uint32_t firstInstance, VkBuffer counterBuffer,
5912 VkDeviceSize counterBufferOffset,
5913 uint32_t counterOffset, uint32_t vertexStride) const {
5914 bool skip = false;
5915
5916 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005917 skip |= LogError(
5918 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005919 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5920 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5921 }
5922
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005923 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005924 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005925 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005926 }
5927
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005928 return skip;
5929}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005930
5931bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5932 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5933 const VkAllocationCallbacks *pAllocator,
5934 VkSamplerYcbcrConversion *pYcbcrConversion,
5935 const char *apiName) const {
5936 bool skip = false;
5937
5938 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005939 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005940 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005941 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005942 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5943 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005944 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005945 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005946 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005947
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005948#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005949 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005950 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005951#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005952 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005953#endif
5954
sfricke-samsung1a72f942020-07-25 12:09:18 -07005955 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005956
5957 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005958 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005959 const VkComponentMapping components = pCreateInfo->components;
5960 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5961 if (FormatIsXChromaSubsampled(format) == true) {
5962 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5963 skip |=
5964 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005965 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5966 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005967 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005968 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005969
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005970 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5971 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5972 skip |= LogError(
5973 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5974 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5975 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5976 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5977 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005978
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005979 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5980 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5981 skip |=
5982 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005983 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5984 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005985 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005986 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005987
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005988 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5989 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5990 skip |=
5991 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005992 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5993 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005994 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005995 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005996
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005997 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005998 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5999 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6000 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006001 skip |=
6002 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006003 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6004 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006005 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6006 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006007 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006008 }
6009
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006010 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6011 // Checks same VU multiple ways in order to give a more useful error message
6012 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6013 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6014 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6015 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6016 skip |= LogError(
6017 device, vuid,
6018 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6019 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6020 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6021 string_VkComponentSwizzle(components.b));
6022 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006023
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006024 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
6025 // 4 channel format = no issue
6026 // 3 = no [a]
6027 // 2 = no [b,a]
6028 // 1 = no [g,b,a]
6029 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
6030 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
6031
6032 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6033 (components.b == VK_COMPONENT_SWIZZLE_A))) {
6034 skip |= LogError(device, vuid,
6035 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6036 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6037 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6038 string_VkComponentSwizzle(components.b));
6039 } else if ((channels < 3) &&
6040 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6041 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6042 skip |= LogError(device, vuid,
6043 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6044 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6045 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6046 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6047 string_VkComponentSwizzle(components.b));
6048 } else if ((channels < 2) &&
6049 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6050 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6051 skip |= LogError(device, vuid,
6052 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6053 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6054 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6055 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6056 string_VkComponentSwizzle(components.b));
6057 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006058 }
6059 }
6060
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006061 return skip;
6062}
6063
6064bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6065 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6066 const VkAllocationCallbacks *pAllocator,
6067 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6068 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6069 "vkCreateSamplerYcbcrConversion");
6070}
6071
6072bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6073 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6074 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6075 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6076 "vkCreateSamplerYcbcrConversionKHR");
6077}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006078
6079bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6080 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6081 bool skip = false;
6082 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6083 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6084
6085 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006086 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6087 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6088 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6089 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6090 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006091 }
6092 return skip;
6093}
sourav parmara96ab1a2020-04-25 16:28:23 -07006094
6095bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006096 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006097 bool skip = false;
6098 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6099 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6100 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6101 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006102 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006103 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6104 skip |= LogError(
6105 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6106 "vkCopyAccelerationStructureToMemoryKHR: The "
6107 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6108 }
6109 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6110 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6111 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6112 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6113 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6114 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006115 return skip;
6116}
6117
6118bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6119 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6120 bool skip = false;
6121 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6122 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6123 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6124 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6125 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006126 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6127 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006128 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006129 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006130 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006131 return skip;
6132}
6133
6134bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6135 const char *api_name) const {
6136 bool skip = false;
6137 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6138 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6139 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6140 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6141 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6142 api_name);
6143 }
6144 return skip;
6145}
6146
6147bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006148 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006149 bool skip = false;
6150 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006151 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006152 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006153 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006154 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6155 "vkCopyAccelerationStructureKHR: The "
6156 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006157 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006158 return skip;
6159}
6160
6161bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6162 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6163 bool skip = false;
6164 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6165 return skip;
6166}
6167
6168bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006169 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006170 bool skip = false;
6171 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006172 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006173 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6174 }
6175 return skip;
6176}
6177
6178bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006179 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006180 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006181 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006182 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006183 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6184 skip |= LogError(
6185 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6186 "vkCopyMemoryToAccelerationStructureKHR: The "
6187 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006188 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006189 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6190 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006191 return skip;
6192}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006193
sourav parmara96ab1a2020-04-25 16:28:23 -07006194bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6195 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6196 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006197 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006198 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6199 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006200 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006201 pInfo->src.deviceAddress);
6202 }
sourav parmar83c31b12020-05-06 12:30:54 -07006203 return skip;
6204}
6205bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6206 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6207 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6208 bool skip = false;
6209 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6210 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6211 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6212 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6213 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6214 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6215 }
6216 return skip;
6217}
6218bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6219 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6220 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6221 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006222 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006223 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6224 skip |= LogError(
6225 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6226 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6227 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6228 }
sourav parmar83c31b12020-05-06 12:30:54 -07006229 if (dataSize < accelerationStructureCount * stride) {
6230 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6231 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
6232 "accelerationStructureCount (%d) *stride(%zu).",
6233 dataSize, accelerationStructureCount, stride);
6234 }
6235 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6236 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6237 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6238 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6239 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6240 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6241 }
6242 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6243 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6244 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6245 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6246 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6247 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6248 stride);
6249 }
6250 }
6251 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6252 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6253 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6254 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6255 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6256 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6257 stride);
6258 }
6259 }
sourav parmar83c31b12020-05-06 12:30:54 -07006260 return skip;
6261}
6262bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6263 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6264 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006265 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006266 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6267 skip |= LogError(
6268 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6269 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6270 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006271 }
6272 return skip;
6273}
6274
6275bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006276 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6277 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6278 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6279 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006280 uint32_t width, uint32_t height, uint32_t depth) const {
6281 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006282 // RayGen
6283 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6284 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6285 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006286 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006287 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6288 0) {
6289 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6290 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6291 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6292 }
6293 // Callable
6294 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6295 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6296 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6297 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006298 }
6299 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6300 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6301 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006302 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6303 }
6304 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6305 0) {
6306 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6307 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6308 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006309 }
6310 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006311 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6312 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6313 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6314 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006315 }
6316 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6317 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006318 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6319 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006320 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006321 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6322 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6323 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6324 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6325 }
sourav parmar83c31b12020-05-06 12:30:54 -07006326 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006327 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6328 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6329 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6330 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006331 }
6332 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6333 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6334 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006335 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6336 }
6337 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6338 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6339 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6340 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6341 }
6342 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6343 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6344 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6345 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6346 }
6347 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6348 skip |=
6349 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6350 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6351 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006352 }
6353
sourav parmarcd5fb182020-07-17 12:58:44 -07006354 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6355 skip |=
6356 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6357 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6358 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6359 }
6360
6361 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6362 skip |=
6363 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6364 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6365 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006366 }
6367 return skip;
6368}
6369
sourav parmarcd5fb182020-07-17 12:58:44 -07006370bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6371 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6372 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6373 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006374 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006375 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006376 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6377 skip |= LogError(
6378 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6379 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6380 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006381 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006382 // RayGen
6383 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6384 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6385 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006386 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006387 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6388 0) {
6389 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6390 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6391 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6392 }
6393 // Callabe
6394 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6395 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6396 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6397 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006398 }
6399 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6400 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006401 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6402 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6403 }
6404 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6405 0) {
6406 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6407 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6408 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006409 }
6410 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006411 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6412 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6413 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6414 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006415 }
6416 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6417 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006418 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6419 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006420 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006421 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6422 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6423 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6424 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6425 }
sourav parmar83c31b12020-05-06 12:30:54 -07006426 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006427 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6428 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6429 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6430 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006431 }
6432 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6433 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006434 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6435 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6436 }
6437 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6438 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6439 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6440 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006441 }
6442
sourav parmarcd5fb182020-07-17 12:58:44 -07006443 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6444 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6445 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006446 }
6447 return skip;
6448}
6449bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6450 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6451 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6452 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6453 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6454 uint32_t width, uint32_t height, uint32_t depth) const {
6455 bool skip = false;
6456 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6457 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6458 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6459 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6460 }
6461 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6462 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6463 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6464 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6465 }
6466 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6467 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6468 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6469 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6470 }
6471
6472 // hitShader
6473 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6474 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6475 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6476 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6477 }
6478 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6479 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6480 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6481 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6482 }
6483 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6484 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6485 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6486 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6487 }
6488
6489 // missShader
6490 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6491 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6492 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6493 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6494 }
6495 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6496 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6497 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6498 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6499 }
6500 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6501 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6502 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6503 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6504 }
6505
6506 // raygenShader
6507 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6508 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6509 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006510 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6511 }
6512 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6513 skip |=
6514 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6515 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6516 }
6517 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6518 skip |=
6519 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6520 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6521 }
6522 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6523 skip |=
6524 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6525 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006526 }
6527 return skip;
6528}
6529
sourav parmar83c31b12020-05-06 12:30:54 -07006530bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006531 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6532 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006533 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006534 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6535 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006536 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6537 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006538 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006539 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6540 }
6541 return skip;
6542}
6543
Piers Daniell39842ee2020-07-10 16:42:33 -06006544bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6545 const VkViewport *pViewports) const {
6546 bool skip = false;
6547
6548 if (!physical_device_features.multiViewport) {
6549 if (viewportCount != 1) {
6550 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6551 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6552 ") is not 1.",
6553 viewportCount);
6554 }
6555 } else { // multiViewport enabled
6556 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6557 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6558 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6559 ") must "
6560 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6561 viewportCount, device_limits.maxViewports);
6562 }
6563 }
6564
6565 if (pViewports) {
6566 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6567 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6568 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6569 skip |= manual_PreCallValidateViewport(
6570 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6571 }
6572 }
6573
6574 return skip;
6575}
6576
6577bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6578 const VkRect2D *pScissors) const {
6579 bool skip = false;
6580
6581 if (!physical_device_features.multiViewport) {
6582 if (scissorCount != 1) {
6583 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6584 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6585 ") must "
6586 "be 1 when the multiViewport feature is disabled.",
6587 scissorCount);
6588 }
6589 } else { // multiViewport enabled
6590 if (scissorCount == 0) {
6591 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6592 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6593 ") must "
6594 "be great than zero.",
6595 scissorCount);
6596 } else if (scissorCount > device_limits.maxViewports) {
6597 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6598 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6599 ") must "
6600 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6601 scissorCount, device_limits.maxViewports);
6602 }
6603 }
6604
6605 if (pScissors) {
6606 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6607 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6608
6609 if (scissor.offset.x < 0) {
6610 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6611 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6612 scissor.offset.x);
6613 }
6614
6615 if (scissor.offset.y < 0) {
6616 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6617 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6618 scissor.offset.y);
6619 }
6620
6621 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6622 if (x_sum > INT32_MAX) {
6623 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6624 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6625 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6626 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6627 }
6628
6629 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6630 if (y_sum > INT32_MAX) {
6631 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6632 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6633 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6634 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6635 }
6636 }
6637 }
6638
6639 return skip;
6640}
6641
6642bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6643 uint32_t bindingCount, const VkBuffer *pBuffers,
6644 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6645 const VkDeviceSize *pStrides) const {
6646 bool skip = false;
6647 if (firstBinding >= device_limits.maxVertexInputBindings) {
6648 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6649 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6650 firstBinding, device_limits.maxVertexInputBindings);
6651 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6652 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6653 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6654 "maxVertexInputBindings (%u)",
6655 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6656 }
6657
6658 for (uint32_t i = 0; i < bindingCount; ++i) {
6659 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006660 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006661 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6662 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6663 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6664 } else {
6665 if (pOffsets[i] != 0) {
6666 skip |=
6667 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6668 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6669 }
6670 }
6671 }
6672 if (pStrides) {
6673 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6674 skip |=
6675 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006676 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i,
Piers Daniell39842ee2020-07-10 16:42:33 -06006677 pStrides[i], device_limits.maxVertexInputBindingStride);
6678 }
6679 }
6680 }
6681
6682 return skip;
6683}
sourav parmarcd5fb182020-07-17 12:58:44 -07006684
6685bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6686 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6687 bool skip = false;
6688 for (uint32_t i = 0; i < infoCount; ++i) {
6689 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6690 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6691 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6692 }
6693 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6694 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6695 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6696 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6697 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6698 api_name);
6699 }
6700 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6701 skip |=
6702 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6703 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6704 }
6705 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6706 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6707 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6708 }
6709 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6710 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6711 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6712 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6713 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6714 api_name);
6715 }
6716 if (pInfos[i].pGeometries) {
6717 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6718 skip |= validate_ranged_enum(
6719 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6720 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6721 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6722 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006723 skip |= validate_struct_type(
6724 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6725 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6726 &(pInfos[i].pGeometries[j].geometry.triangles),
6727 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6728 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6729 skip |= validate_struct_pnext(
6730 api_name,
6731 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6732 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6733 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6734 skip |=
6735 validate_ranged_enum(api_name,
6736 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6737 ParameterName::IndexVector{i, j}),
6738 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6739 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6740 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6741 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6742 &pInfos[i].pGeometries[j].geometry.triangles,
6743 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6744 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6745 skip |= validate_ranged_enum(
6746 api_name,
6747 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6748 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6749 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6750
6751 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6752 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6753 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6754 }
6755 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6756 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6757 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6758 skip |=
6759 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6760 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6761 api_name);
6762 }
6763 }
6764 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6765 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6766 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6767 &pInfos[i].pGeometries[j].geometry.instances,
6768 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6769 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6770 skip |= validate_struct_type(
6771 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6772 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6773 &(pInfos[i].pGeometries[j].geometry.instances),
6774 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6775 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6776 skip |= validate_struct_pnext(
6777 api_name,
6778 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6779 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6780 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6781
6782 skip |= validate_bool32(api_name,
6783 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6784 ParameterName::IndexVector{i, j}),
6785 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6786 }
6787 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6788 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6789 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6790 &pInfos[i].pGeometries[j].geometry.aabbs,
6791 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6792 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6793 skip |= validate_struct_type(
6794 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6795 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6796 &(pInfos[i].pGeometries[j].geometry.aabbs),
6797 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6798 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6799 skip |= validate_struct_pnext(
6800 api_name,
6801 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6802 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6803 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6804 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6805 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6806 "(%s):stride must be less than or equal to 2^32-1", api_name);
6807 }
6808 }
6809 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6810 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6811 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6812 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6813 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6814 api_name);
6815 }
6816 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6817 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6818 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6819 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6820 "of elements of"
6821 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6822 api_name);
6823 }
6824 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6825 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6826 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6827 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6828 api_name);
6829 }
6830 }
6831 }
6832 }
6833 if (pInfos[i].ppGeometries != NULL) {
6834 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6835 skip |= validate_ranged_enum(
6836 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6837 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6838 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6839 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006840 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6841 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6842 &pInfos[i].ppGeometries[j]->geometry.triangles,
6843 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6844 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6845 skip |= validate_struct_type(
6846 api_name,
6847 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6848 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6849 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6850 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6851 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6852 skip |= validate_struct_pnext(
6853 api_name,
6854 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6855 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6856 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6857 skip |= validate_ranged_enum(api_name,
6858 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6859 ParameterName::IndexVector{i, j}),
6860 "VkFormat", AllVkFormatEnums,
6861 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6862 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6863 skip |= validate_ranged_enum(api_name,
6864 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6865 ParameterName::IndexVector{i, j}),
6866 "VkIndexType", AllVkIndexTypeEnums,
6867 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6868 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6869 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6870 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6871 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6872 }
6873 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6874 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6875 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6876 skip |=
6877 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6878 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6879 api_name);
6880 }
6881 }
6882 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6883 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6884 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6885 &pInfos[i].ppGeometries[j]->geometry.instances,
6886 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6887 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6888 skip |= validate_struct_type(
6889 api_name,
6890 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6891 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6892 &(pInfos[i].ppGeometries[j]->geometry.instances),
6893 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6894 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6895 skip |= validate_struct_pnext(
6896 api_name,
6897 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6898 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6899 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6900 skip |= validate_bool32(api_name,
6901 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6902 ParameterName::IndexVector{i, j}),
6903 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6904 }
6905 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6906 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6907 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6908 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6909 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6910 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6911 skip |= validate_struct_type(
6912 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6913 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6914 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6915 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6916 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6917 skip |= validate_struct_pnext(
6918 api_name,
6919 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6920 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6921 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6922 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6923 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6924 "(%s):stride must be less than or equal to 2^32-1", api_name);
6925 }
6926 }
6927 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6928 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6929 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6930 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6931 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6932 api_name);
6933 }
6934 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6935 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6936 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6937 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6938 "of elements of"
6939 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6940 api_name);
6941 }
6942 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6943 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6944 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6945 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6946 api_name);
6947 }
6948 }
6949 }
6950 }
6951 }
6952 return skip;
6953}
6954bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6955 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6956 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6957 bool skip = false;
6958 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6959 for (uint32_t i = 0; i < infoCount; ++i) {
6960 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6961 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6962 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6963 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6964 "scratchData.deviceAddress member must be a multiple of "
6965 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6966 }
6967 for (uint32_t k = 0; k < infoCount; ++k) {
6968 if (i == k) continue;
6969 bool found = false;
6970 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6971 skip |= LogError(
6972 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6973 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6974 "not be "
6975 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6976 i, k);
6977 found = true;
6978 }
6979 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6980 skip |= LogError(
6981 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6982 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6983 "not be "
6984 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6985 i, k);
6986 found = true;
6987 }
6988 if (found) break;
6989 }
6990 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6991 if (pInfos[i].pGeometries) {
6992 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6993 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6994 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6995 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6996 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6997 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6998 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6999 }
7000 } else {
7001 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7002 skip |=
7003 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7004 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7005 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7006 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7007 }
7008 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007009 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007010 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7011 skip |= LogError(
7012 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7013 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7014 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7015 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007016 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7017 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007018 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7019 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7020 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7021 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7022 }
7023 }
7024 } else if (pInfos[i].ppGeometries) {
7025 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7026 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7027 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7028 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7029 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7030 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7031 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7032 }
7033 } else {
7034 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7035 skip |=
7036 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7037 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7038 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7039 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7040 }
7041 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007042 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007043 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7044 skip |= LogError(
7045 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7046 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7047 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7048 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007049 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7050 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007051 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7052 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7053 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7054 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7055 }
7056 }
7057 }
7058 }
7059 }
7060 return skip;
7061}
7062
7063bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7064 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7065 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7066 const uint32_t *const *ppMaxPrimitiveCounts) const {
7067 bool skip = false;
7068 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7069 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007070 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007071 if (!ray_tracing_acceleration_structure_features ||
7072 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7073 skip |= LogError(
7074 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7075 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7076 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7077 }
7078 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007079 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7080 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7081 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7082 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7083 "scratchData.deviceAddress member must be a multiple of "
7084 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7085 }
7086 for (uint32_t k = 0; k < infoCount; ++k) {
7087 if (i == k) continue;
7088 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
7089 skip |=
7090 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7091 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
7092 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7093 "any other element [%d) of pInfos.",
7094 i, k);
7095 break;
7096 }
7097 }
7098 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7099 if (pInfos[i].pGeometries) {
7100 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7101 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7102 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7103 skip |= LogError(
7104 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7105 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7106 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7107 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7108 }
7109 } else {
7110 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7111 skip |= LogError(
7112 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7113 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7114 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7115 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7116 }
7117 }
7118 }
7119 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7120 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7121 skip |= LogError(
7122 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7123 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7124 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7125 }
7126 }
7127 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7128 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7129 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7130 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7131 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7132 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7133 }
7134 }
7135 } else if (pInfos[i].ppGeometries) {
7136 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7137 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7138 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7139 skip |= LogError(
7140 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7141 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7142 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7143 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7144 }
7145 } else {
7146 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7147 skip |= LogError(
7148 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7149 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7150 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7151 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7152 }
7153 }
7154 }
7155 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7156 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7157 skip |= LogError(
7158 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7159 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7160 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7161 }
7162 }
7163 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7164 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7165 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7166 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7167 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7168 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7169 }
7170 }
7171 }
7172 }
7173 }
7174 return skip;
7175}
7176
7177bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7178 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7179 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7180 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7181 bool skip = false;
7182 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7183 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007184 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007185 if (!ray_tracing_acceleration_structure_features ||
7186 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7187 skip |=
7188 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7189 "vkBuildAccelerationStructuresKHR: The "
7190 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7191 }
7192 for (uint32_t i = 0; i < infoCount; ++i) {
7193 for (uint32_t j = 0; j < infoCount; ++j) {
7194 if (i == j) continue;
7195 bool found = false;
7196 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7197 skip |= LogError(
7198 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7199 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
7200 "not be "
7201 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7202 i, j);
7203 found = true;
7204 }
7205 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7206 skip |= LogError(
7207 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7208 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
7209 "not be "
7210 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7211 i, j);
7212 found = true;
7213 }
7214 if (found) break;
7215 }
7216 }
7217 return skip;
7218}
7219
7220bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7221 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7222 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7223 bool skip = false;
7224 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7225 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007226 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7227 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007228 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7229 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7230 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7231 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7232 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7233 }
7234 return skip;
7235}
sfricke-samsungecafb192021-01-17 08:21:14 -08007236
7237bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7238 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7239 const VkAllocationCallbacks *pAllocator,
7240 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7241 bool skip = false;
7242 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7243 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7244 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7245 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7246 }
7247 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007248}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007249
7250bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7251 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7252 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7253 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7254 bool skip = false;
7255 const auto *vertex_input_dynamic_state_features =
7256 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7257 const auto *vertex_attribute_divisor_features =
7258 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7259
7260 // VUID-vkCmdSetVertexInputEXT-None-04790
7261 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7262 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7263 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7264 }
7265
7266 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7267 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7268 skip |=
7269 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7270 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7271 }
7272
7273 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7274 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7275 skip |= LogError(
7276 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7277 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7278 }
7279
7280 // VUID-vkCmdSetVertexInputEXT-binding-04793
7281 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7282 bool binding_found = false;
7283 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7284 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7285 binding_found = true;
7286 break;
7287 }
7288 }
7289 if (!binding_found) {
7290 skip |=
7291 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7292 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
7293 }
7294 }
7295
7296 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7297 if (vertexBindingDescriptionCount > 1) {
7298 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7299 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7300 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7301 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7302 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
7303 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
7304 }
7305 }
7306 }
7307 }
7308
7309 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7310 if (vertexAttributeDescriptionCount > 1) {
7311 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7312 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7313 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7314 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7315 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
7316 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
7317 }
7318 }
7319 }
7320 }
7321
7322 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7323 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7324 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
7325 skip |= LogError(
7326 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7327 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
7328 }
7329
7330 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7331 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
7332 skip |= LogError(
7333 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7334 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
7335 binding);
7336 }
7337
7338 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7339 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7340 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7341 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7342 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7343 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7344 binding);
7345 }
7346
7347 if (pVertexBindingDescriptions[binding].divisor > 1) {
7348 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7349 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7350 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7351 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7352 "vertexAttributeInstanceRateDivisor is not enabled",
7353 binding);
7354 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007355 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007356 if (pVertexBindingDescriptions[binding].divisor >
7357 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7358 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007359 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007360 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7361 binding);
7362 }
7363
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007364 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007365 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7366 skip |=
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007367 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007368 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7369 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7370 binding);
7371 }
7372 }
7373 }
7374 }
7375
7376 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007377 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007378 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7379 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007380 device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007381 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7382 attribute);
7383 }
7384
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007385 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007386 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7387 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007388 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007389 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7390 attribute);
7391 }
7392
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007393 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007394 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7395 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007396 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007397 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7398 attribute);
7399 }
7400
7401 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7402 VkFormatProperties properties;
7403 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7404 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7405 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7406 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7407 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7408 attribute);
7409 }
7410 }
7411
7412 return skip;
7413}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007414
7415bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7416 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7417 const void *pValues) const {
7418 bool skip = false;
7419 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7420 // Check that offset + size don't exceed the max.
7421 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7422 if (offset >= max_push_constants_size) {
7423 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7424 "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset,
7425 max_push_constants_size);
7426 }
7427 if (size > max_push_constants_size - offset) {
7428 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
7429 "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.",
7430 offset, size, max_push_constants_size);
7431 }
7432
7433 // size needs to be non-zero and a multiple of 4.
7434 if (size & 0x3) {
7435 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.",
7436 size);
7437 }
7438
7439 // offset needs to be a multiple of 4.
7440 if ((offset & 0x3) != 0) {
7441 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007442 "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007443 }
7444 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007445}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007446
7447bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7448 uint32_t srcCacheCount,
7449 const VkPipelineCache *pSrcCaches) const {
7450 bool skip = false;
7451 if (pSrcCaches) {
7452 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7453 if (pSrcCaches[index0] == dstCache) {
7454 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7455 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7456 report_data->FormatHandle(dstCache).c_str());
7457 break;
7458 }
7459 }
7460 }
7461 return skip;
7462}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007463
7464bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
7465 VkImageLayout imageLayout, const VkClearColorValue *pColor,
7466 uint32_t rangeCount,
7467 const VkImageSubresourceRange *pRanges) const {
7468 bool skip = false;
7469 if (!pColor) {
7470 skip |=
7471 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
7472 }
7473 return skip;
7474}
7475
7476bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
7477 const VkRenderPassBeginInfo *const rp_begin) const {
7478 bool skip = false;
7479 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
7480 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
7481 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
7482 "), but VkRenderPassBeginInfo::pClearValues is not null.",
7483 func_name, rp_begin->clearValueCount);
7484 }
7485 return skip;
7486}
7487
7488bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7489 VkSubpassContents) const {
7490 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
7491 return skip;
7492}
7493
7494bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
7495 const VkRenderPassBeginInfo *pRenderPassBegin,
7496 const VkSubpassBeginInfo *) const {
7497 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
7498 return skip;
7499}
7500
7501bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7502 const VkSubpassBeginInfo *) const {
7503 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
7504 return skip;
7505}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02007506
7507bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
7508 uint32_t firstDiscardRectangle,
7509 uint32_t discardRectangleCount,
7510 const VkRect2D *pDiscardRectangles) const {
7511 bool skip = false;
7512
7513 if (pDiscardRectangles) {
7514 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
7515 const int64_t x_sum =
7516 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
7517 if (x_sum > std::numeric_limits<int32_t>::max()) {
7518 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
7519 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7520 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7521 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
7522 }
7523
7524 const int64_t y_sum =
7525 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
7526 if (y_sum > std::numeric_limits<int32_t>::max()) {
7527 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
7528 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7529 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7530 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
7531 }
7532 }
7533 }
7534
7535 return skip;
7536}