blob: fdfa14a6712c9079a552d2236a04361feec0bc30 [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"
sfricke-samsung2e827212021-09-28 07:52:08 -070027#include "core_validation_error_enums.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010028
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070029static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060030
John Zulauf71968502017-10-26 13:51:15 -060031template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070032inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060033 // Using only < for generality and || for early abort
34 return !((value < min) || (max < value));
35}
36
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070037read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); }
38write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); }
39
Jeremy Gebbencbf22862021-03-03 12:01:22 -070040static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070041static ReadWriteLock secondary_cb_map_mutex;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -070042static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); }
43static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070044
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070045bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050046 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 bool skip = false;
48
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070049 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050
51 if (result == VK_STRING_ERROR_NONE) {
52 return skip;
53 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070054 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070055 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060056 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070057 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
58 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060059 }
60 return skip;
61}
62
Jeff Bolz46c0ea02019-10-09 13:06:29 -050063bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060064 bool skip = false;
65 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
66 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080067 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
68 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070069 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
70 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
71 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060072 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070073 skip |= LogWarning(instance, kVUIDUndefined,
74 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
75 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
76 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060077 }
78 }
79 return skip;
80}
81
Jeff Bolz46c0ea02019-10-09 13:06:29 -050082bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060083 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060084 // Create and use a local instance extension object, as an actual instance has not been created yet
85 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
86 InstanceExtensions local_instance_extensions;
87 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
88
John Zulauf620755c2018-04-16 11:00:43 -060089 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060090 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
91 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060092 }
93
94 return skip;
95}
96
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060097bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -070098 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060099 // Struct is legal IF it's supported
100 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
101 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
102 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
103 if (enum_iter != dev_exts_enumerated->second.cend()) {
104 return true;
105 }
106 }
107 return false;
108}
109
Tony-LunarG866843d2020-05-13 11:22:42 -0600110bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
111 const VkValidationFeaturesEXT *validation_features) const {
112 bool skip = false;
113 bool debug_printf = false;
114 bool gpu_assisted = false;
115 bool reserve_slot = false;
116 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
117 switch (validation_features->pEnabledValidationFeatures[i]) {
118 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
119 gpu_assisted = true;
120 break;
121
122 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
123 debug_printf = true;
124 break;
125
126 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
127 reserve_slot = true;
128 break;
129
130 default:
131 break;
132 }
133 }
134 if (reserve_slot && !gpu_assisted) {
135 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
136 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
137 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
138 }
139 if (gpu_assisted && debug_printf) {
140 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
141 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
142 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
143 }
144
145 return skip;
146}
147
John Zulauf620755c2018-04-16 11:00:43 -0600148template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700149ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
150 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600151 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700152 ExtEnabled state =
153 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600154 return state;
155}
156
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700157bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500158 const VkAllocationCallbacks *pAllocator,
159 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700160 bool skip = false;
161 // Note: From the spec--
162 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
163 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
164 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700165 ? pCreateInfo->pApplicationInfo->apiVersion
166 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700167 skip |= validate_api_version(local_api_version, api_version);
168 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700169 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600170 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
171
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700172 return skip;
173}
174
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700175void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700176 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
177 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700178 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
179 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700180 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700181 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700182}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600183
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700184void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
185 // Assume phys_devices is valid
186 assert(phys_devices);
187 for (int i = 0; i < count; ++i) {
188 const auto &phys_device = phys_devices[i];
189 if (0 == physical_device_properties_map.count(phys_device)) {
190 auto phys_dev_props = new VkPhysicalDeviceProperties;
191 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
192 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600193
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700194 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
195 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700196 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700197 std::vector<VkExtensionProperties> ext_props{};
198 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
199 ext_props.resize(ext_count);
200 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
201 for (uint32_t j = 0; j < ext_count; j++) {
202 dev_exts_enumerated.insert(ext_props[j].extensionName);
203 }
204 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600205 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700206 }
207}
208
209void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
210 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
211 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
212 return;
213 }
214
215 if (pPhysicalDeviceCount && pPhysicalDevices) {
216 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
217 }
218}
219
220void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
221 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
222 VkResult result) {
223 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
224 return;
225 }
226
227 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
228 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
229 const auto &group = pPhysicalDeviceGroupProperties[i];
230 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
231 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600232 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700233}
234
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600235void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
236 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
237 delete (it->second);
238 it = physical_device_properties_map.erase(it);
239 }
240};
241
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700242void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700243 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700244 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700245 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700246 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
247 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700249 // Parmeter validation also uses extension data
250 stateless_validation->device_extensions = this->device_extensions;
251
252 VkPhysicalDeviceProperties device_properties = {};
253 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600254 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700255 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
256
sfricke-samsung45996a42021-09-16 13:45:27 -0700257 if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700258 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700259 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
260 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600261 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700262 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
263 }
264
sfricke-samsung45996a42021-09-16 13:45:27 -0700265 if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700266 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700267 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
268 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600269 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700270 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
271 }
272
sfricke-samsung45996a42021-09-16 13:45:27 -0700273 if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) {
Jason Macnak5c954952019-07-09 15:46:12 -0700274 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700275 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
276 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700277 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500278 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
279 }
280
sfricke-samsung45996a42021-09-16 13:45:27 -0700281 if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500282 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700283 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
284 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500285 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
286 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700287 }
288
sfricke-samsung45996a42021-09-16 13:45:27 -0700289 if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) {
sourav parmarcd5fb182020-07-17 12:58:44 -0700290 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700291 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
292 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700293 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
294 phys_dev_ext_props.acc_structure_props = acc_structure_props;
295 }
296
sfricke-samsung45996a42021-09-16 13:45:27 -0700297 if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) {
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700298 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700299 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
300 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700301 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
302 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
303 }
304
sfricke-samsung45996a42021-09-16 13:45:27 -0700305 if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) {
Piers Daniellcb6d8032021-04-19 18:51:26 -0600306 // Get the needed vertex attribute divisor limits
307 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
308 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
309 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
310 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
311 }
312
sfricke-samsung45996a42021-09-16 13:45:27 -0700313 if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) {
ziga-lunarga283d022021-08-04 18:35:23 +0200314 // Get the needed vertex attribute divisor limits
315 auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>();
316 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props);
317 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
318 phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props;
319 }
320
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800321 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
322
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700323 // Save app-enabled features in this device's validation object
324 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700325 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200326 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
327 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
328 if (features2) {
329 tmp_features2_state.features = features2->features;
330 } else if (pCreateInfo->pEnabledFeatures) {
331 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700332 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200333 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700334 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200335 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700336 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200337 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700338}
339
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700340bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500341 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600342 bool skip = false;
343
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200344 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
345 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
346 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600347 }
348
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700349 // If this device supports VK_KHR_portability_subset, it must be enabled
350 const std::string portability_extension_name("VK_KHR_portability_subset");
351 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
352 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
353 bool portability_requested = false;
354
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200355 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
356 skip |=
357 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
358 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
359 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
360 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700361 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
362 portability_requested = true;
363 }
364 }
365
366 if (portability_supported && !portability_requested) {
367 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
368 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
369 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600370 }
371
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200372 {
Mike Schuchardt7cc57842021-09-15 10:49:59 -0700373 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME));
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700374 bool negative_viewport =
375 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200376 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700377 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
378 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
379 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200380 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600381 }
382
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600383 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200384 bool khr_bda =
385 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
386 bool ext_bda =
387 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600388 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700389 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
390 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
391 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600392 }
393 }
394
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600395 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
396 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700397 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600398 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800399 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700400 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800401 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700402 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600403 }
404 }
405
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700406 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500407 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700408 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500409 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
410 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
411 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
412 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700413 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700414 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
415 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
416 skip |= LogError(
417 device,
418 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
419 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
420 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700421 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700422 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -0700423 if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) {
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600424 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
425 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
426 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600427 }
428
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700429 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700430 if (vulkan_11_features) {
431 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
432 while (current) {
433 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
434 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
435 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
436 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
437 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
438 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700439 skip |= LogError(
440 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700441 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
442 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
443 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
444 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
445 break;
446 }
447 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
448 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800449
450 // Check features are enabled if matching extension is passed in as well
451 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
452 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
453 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
454 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
455 skip |= LogError(
456 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
457 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
458 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
459 }
460 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700461 }
462
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700463 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700464 if (vulkan_12_features) {
465 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
466 while (current) {
467 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
469 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
470 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
471 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
472 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
473 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
474 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
475 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
476 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
477 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
478 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
479 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700480 skip |= LogError(
481 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700482 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
483 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
484 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
485 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
486 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
487 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
488 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
489 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
490 break;
491 }
492 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
493 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700494 // Check features are enabled if matching extension is passed in as well
495 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
496 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
497 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
498 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
499 skip |= LogError(
500 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
501 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
502 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
503 }
504 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
505 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
506 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
507 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
508 "is not VK_TRUE.",
509 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
510 }
511 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
512 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
513 skip |= LogError(
514 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
515 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
516 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
517 }
518 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
519 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
520 skip |= LogError(
521 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
522 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
523 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
524 }
525 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
526 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
527 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
528 skip |=
529 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
530 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
531 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
532 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
533 }
534 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200535 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
536 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
537 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
538 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
539 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
540 }
541 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700542 }
543
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600544 // Validate pCreateInfo->pQueueCreateInfos
545 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600546
547 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700548 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
549 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600550 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700551 skip |=
552 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
553 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
554 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
555 "index value.",
556 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600557 }
558
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700559 if (queue_create_info.pQueuePriorities != nullptr) {
560 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
561 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600562 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700563 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
564 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
565 "] (=%f) is not between 0 and 1 (inclusive).",
566 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600567 }
568 }
569 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700570
571 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700572 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700573 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700574 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700575 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700576 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700577 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700578 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700579 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700580 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700581 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
582 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
583 "protectedMemory feature being set as well.");
584 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600585 }
586 }
587
sfricke-samsung30a57412020-05-15 21:14:54 -0700588 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700589 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700590 VkBool32 variable_pointers = VK_FALSE;
591 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700592 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700593 variable_pointers = vulkan_11_features->variablePointers;
594 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700595 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700596 variable_pointers = variable_pointers_features->variablePointers;
597 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700598 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700599 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700600 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
601 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
602 }
603
sfricke-samsungfd76c342020-05-29 23:13:43 -0700604 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700605 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700606 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700607 VkBool32 multiview_geometry_shader = VK_FALSE;
608 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700609 if (vulkan_11_features) {
610 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700611 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
612 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700613 } else if (multiview_features) {
614 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700615 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
616 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700617 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700618 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700619 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
620 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
621 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700622 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700623 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
624 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
625 }
626
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600627 return skip;
628}
629
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500630bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700631 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700632 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
633 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
634 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600635 }
636
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700637 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600638}
639
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700640bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500641 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100642 bool skip = false;
643
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600644 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700645 skip |=
646 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600647
648 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
649 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
650 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
651 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700652 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
653 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
654 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600655 }
656
657 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
658 // queueFamilyIndexCount uint32_t values
659 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700660 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
661 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
662 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
663 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600664 }
665 }
666
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700667 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
668 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
669 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
670 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
671 }
672
673 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
674 skip |=
675 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
676 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
677 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
678 }
679
680 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
681 skip |=
682 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
683 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
684 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
685 }
686
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600687 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
688 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
689 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
690 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700691 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
692 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
693 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600694 }
695 }
696
697 return skip;
698}
699
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700700bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500701 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600702 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703
704 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800705 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700706 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600707 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
708 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
709 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
710 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
712 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
713 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714 }
715
716 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
717 // queueFamilyIndexCount uint32_t values
718 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700719 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
720 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
721 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
722 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600723 }
724 }
725
Dave Houlton413a6782018-05-22 13:01:54 -0600726 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700727 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600728 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700729 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600730 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700731 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600732
Dave Houlton413a6782018-05-22 13:01:54 -0600733 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700734 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600735 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700736 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600737
Dave Houlton130c0212018-01-29 13:39:56 -0700738 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700739 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
740 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700741 skip |= LogError(
742 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600743 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
744 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700745 }
746
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600747 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100748 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
749 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
751 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
752 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 }
754
755 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700756 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100757 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700758 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
759 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
760 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
761 ") are not equal.",
762 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100763 }
764
765 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
767 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
768 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
769 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100770 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600771 }
772
773 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700774 skip |= LogError(
775 device, "VUID-VkImageCreateInfo-imageType-00957",
776 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600777 }
778 }
779
Dave Houlton130c0212018-01-29 13:39:56 -0700780 // 3D image may have only 1 layer
781 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700782 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
783 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700784 }
785
Dave Houlton130c0212018-01-29 13:39:56 -0700786 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
787 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
788 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
789 // At least one of the legal attachment bits must be set
790 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700791 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
792 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700793 }
794 // No flags other than the legal attachment bits may be set
795 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
796 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
798 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700799 }
800 }
801
Jeff Bolzef40fec2018-09-01 22:04:34 -0500802 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700803 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500804 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700805 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700806 ? static_cast<uint32_t>(ceil(log2(max_dim)))
807 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
808 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600809 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700810 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
811 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
812 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600813 }
814
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700815 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700816 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
817 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
818 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600819 }
820
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700821 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700822 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
823 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
824 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100825 }
826
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700827 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700828 skip |= LogError(
829 device, "VUID-VkImageCreateInfo-flags-01924",
830 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
831 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
832 }
833
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600834 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
835 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700836 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
837 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700838 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
839 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
840 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600841 }
842
843 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700844 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600845 // Linear tiling is unsupported
846 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700847 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700848 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
849 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600850 }
851
852 // Sparse 1D image isn't valid
853 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700854 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
855 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600856 }
857
858 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700859 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700860 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
861 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
862 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600863 }
864
865 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700866 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700867 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
868 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
869 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600870 }
871
872 // Multi-sample 2D image when device doesn't support it
873 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700874 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600875 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700876 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
877 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
878 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700879 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600880 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700881 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
882 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
883 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700884 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600885 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700886 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
887 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
888 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700889 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600890 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700891 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
892 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
893 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600894 }
895 }
896 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500897
Jeff Bolz9af91c52018-09-01 21:53:57 -0500898 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
899 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700900 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
901 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
902 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500903 }
904 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700905 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
906 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
907 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500908 }
909 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700910 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
911 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
912 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500913 }
914 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500915
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700916 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600917 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700918 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
919 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
920 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500921 }
922
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700923 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700924 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
925 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800926 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
927 "depth/stencil format.",
928 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500929 }
930
Dave Houlton142c4cb2018-10-17 15:04:41 -0600931 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700932 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
933 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
934 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
935 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500936 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600937 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700938 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
939 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
940 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
941 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500942 }
943 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500944
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700945 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800946 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700947 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
948 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800949 "format (%s) must be a depth or depth/stencil format.",
950 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700951 }
952
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700953 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500954 if (image_stencil_struct != nullptr) {
955 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
956 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
957 // No flags other than the legal attachment bits may be set
958 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
959 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700960 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
961 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
962 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
963 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500964 }
965 }
966
sfricke-samsung61a57c02021-01-10 21:35:12 -0800967 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500968 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
969 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -0700970 skip |=
971 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
972 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
973 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32
974 ") exceeds device "
975 "maxFramebufferWidth (%" PRIu32 ")",
976 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500977 }
978
979 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -0700980 skip |=
981 LogError(device, "VUID-VkImageCreateInfo-format-02537",
982 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
983 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32
984 ") exceeds device "
985 "maxFramebufferHeight (%" PRIu32 ")",
986 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500987 }
988 }
989
990 if (!physical_device_features.shaderStorageImageMultisample &&
991 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
992 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
993 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700994 LogError(device, "VUID-VkImageCreateInfo-format-02538",
995 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
996 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
997 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500998 }
999
1000 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
1001 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001002 skip |= LogError(
1003 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001004 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1005 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1006 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1007 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1008 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001009 skip |= LogError(
1010 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001011 "vkCreateImage(): Depth-stencil image in which usage does not include "
1012 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1013 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1014 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1015 }
1016
1017 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1018 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001019 skip |= LogError(
1020 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001021 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1022 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1023 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1024 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1025 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001026 skip |= LogError(
1027 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001028 "vkCreateImage(): Depth-stencil image in which usage does not include "
1029 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1030 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1031 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1032 }
1033 }
1034 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001035
1036 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1037 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1038 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1039 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1040 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1041 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001042
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001043 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001044 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001045 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1046 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001047 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1048 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1049 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1050 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1051 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1052 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1053 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001054 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001055 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1056 } else if (drm_format_mod_list != nullptr) {
1057 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1058 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1059 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001060 }
1061 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1062 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1063 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1064 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1065 "in the pNext chain");
1066 }
1067 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001068
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001069 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001070 bool image_create_maybe_linear = false;
1071 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1072 image_create_maybe_linear = true;
1073 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1074 image_create_maybe_linear = false;
1075 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1076 image_create_maybe_linear =
1077 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001078 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001079 }
1080
1081 // If multi-sample, validate type, usage, tiling and mip levels.
1082 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001083 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001084 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1085 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1086 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1087 }
1088
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001089 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001090 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1091 image_create_maybe_linear)) {
1092 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1093 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1094 }
1095
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001096 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1097 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1098 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1099 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1100 "imageType must be VK_IMAGE_TYPE_2D.");
1101 }
1102 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1103 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1104 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1105 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1106 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001107 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001108 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001109 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1110 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1111 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1112 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1113 }
1114 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1115 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1116 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1117 "imageType must be VK_IMAGE_TYPE_2D.");
1118 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001119 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001120 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1121 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1122 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1123 }
1124 if (pCreateInfo->mipLevels != 1) {
1125 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001126 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32
1127 ") must be 1.",
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001128 pCreateInfo->mipLevels);
1129 }
1130 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001131
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001132 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001133 if (swapchain_create_info != nullptr) {
1134 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1135 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1136 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1137 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1138 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1139 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1140
1141 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1142 // also implicitly forces the check above that extent.depth is 1
1143 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1144 string_VkImageType(pCreateInfo->imageType));
1145 }
1146 if (pCreateInfo->mipLevels != 1) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001147 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %" PRIu32 ".", base_message,
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001148 pCreateInfo->mipLevels);
1149 }
1150 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1151 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1152 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1153 }
1154 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1155 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1156 base_message, string_VkImageTiling(pCreateInfo->tiling));
1157 }
1158 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1159 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1160 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1161 }
1162 const VkImageCreateFlags valid_flags =
1163 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001164 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001165 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001166 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001167 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001168 }
1169 }
1170 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001171
1172 // If Chroma subsampled format ( _420_ or _422_ )
1173 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1174 skip |=
1175 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1176 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1177 ") must be a multiple of 2.",
1178 string_VkFormat(image_format), pCreateInfo->extent.width);
1179 }
1180 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1181 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1182 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1183 ") must be a multiple of 2.",
1184 string_VkFormat(image_format), pCreateInfo->extent.height);
1185 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001186
1187 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1188 if (format_list_info) {
1189 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1190 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1191 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1192 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001193 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.",
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001194 viewFormatCount);
1195 }
1196 // Check if viewFormatCount is not zero that it is all compatible
1197 for (uint32_t i = 0; i < viewFormatCount; i++) {
1198 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1199 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001200 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1201 "] (%s) and "
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001202 "VkImageCreateInfo::format (%s) are not compatible.",
Esther O'Keefed37c24b2021-09-27 12:45:40 +10001203 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001204 }
1205 }
1206 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001207 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001208
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001209 return skip;
1210}
1211
Jeff Bolz99e3f632020-03-24 22:59:22 -05001212bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1213 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1214 bool skip = false;
1215
1216 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001217 // Validate feature set if using CUBE_ARRAY
1218 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1219 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1220 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1221 "enabling the imageCubeArray feature.");
1222 }
1223
Jeff Bolz99e3f632020-03-24 22:59:22 -05001224 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1225 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1226 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001227 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1228 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001229 pCreateInfo->subresourceRange.layerCount);
1230 }
1231 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001232 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1233 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1234 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1235 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001236 }
1237 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001238
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001239 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001240 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001241 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1242 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1243 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1244 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1245 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1246 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1247 }
1248 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1249 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1250 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1251 "not an ASTC format.",
1252 string_VkFormat(pCreateInfo->format));
1253 }
1254 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001255
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001256 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001257 if (ycbcr_conversion != nullptr) {
1258 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1259 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1260 skip |= LogError(
1261 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1262 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1263 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1264 "r swizzle = %s\n"
1265 "g swizzle = %s\n"
1266 "b swizzle = %s\n"
1267 "a swizzle = %s\n",
1268 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1269 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1270 }
1271 }
1272 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001273 }
1274 return skip;
1275}
1276
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001277bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001278 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001279 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001280
1281 // Note: for numerical correctness
1282 // - float comparisons should expect NaN (comparison always false).
1283 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1284
1285 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001286 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001287 if (v1_f <= 0.0f) return true;
1288
1289 float intpart;
1290 const float fract = modff(v1_f, &intpart);
1291
1292 assert(std::numeric_limits<float>::radix == 2);
1293 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1294 if (intpart >= u32_max_plus1) return false;
1295
1296 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001297 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001298 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001299 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001300 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001301 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001302 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001303 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001304 };
1305
1306 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1307 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1308 return (v1_f <= v2_f);
1309 };
1310
1311 // width
1312 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001313 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001314
1315 if (!(viewport.width > 0.0f)) {
1316 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001317 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1318 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001319 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1320 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001321 skip |= LogError(object, "VUID-VkViewport-width-01771",
1322 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1323 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001324 }
1325
1326 // height
1327 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001328 const bool negative_height_enabled =
1329 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001330 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001331
1332 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1333 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001334 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1335 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001336 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1337 height_healthy = false;
1338
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001339 skip |= LogError(object, "VUID-VkViewport-height-01773",
1340 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1341 ").",
1342 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001343 }
1344
1345 // x
1346 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001347 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001348 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001349 skip |= LogError(object, "VUID-VkViewport-x-01774",
1350 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1351 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001352 }
1353
1354 // x + width
1355 if (x_healthy && width_healthy) {
1356 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001357 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001358 skip |= LogError(
1359 object, "VUID-VkViewport-x-01232",
1360 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1361 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1362 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001363 }
1364 }
1365
1366 // y
1367 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001368 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001369 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001370 skip |= LogError(object, "VUID-VkViewport-y-01775",
1371 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1372 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001373 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001374 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001375 skip |= LogError(object, "VUID-VkViewport-y-01776",
1376 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1377 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001378 }
1379
1380 // y + height
1381 if (y_healthy && height_healthy) {
1382 const float boundary = viewport.y + viewport.height;
1383
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001384 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001385 skip |= LogError(object, "VUID-VkViewport-y-01233",
1386 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1387 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1388 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001389 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001390 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001391 LogError(object, "VUID-VkViewport-y-01777",
1392 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1393 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1394 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001395 }
1396 }
1397
sfricke-samsungfd06d422021-01-22 02:17:21 -08001398 // The extension was not created with a feature bit whichs prevents displaying the 2 variations of the VUIDs
sfricke-samsung45996a42021-09-16 13:45:27 -07001399 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001400 // minDepth
1401 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001402 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001403 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001404 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1405 "[0.0, 1.0] range.",
1406 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001407 }
1408
1409 // maxDepth
1410 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001411 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001412 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001413 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1414 "[0.0, 1.0] range.",
1415 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001416 }
1417 }
1418
1419 return skip;
1420}
1421
Dave Houlton142c4cb2018-10-17 15:04:41 -06001422struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001423 VkShadingRatePaletteEntryNV shadingRate;
1424 uint32_t width;
1425 uint32_t height;
1426};
1427
1428// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001429static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001430 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1431 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1432 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1433 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1434 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1435 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001436};
1437
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001438bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001439 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001440
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001441 SampleOrderInfo *sample_order_info;
1442 uint32_t info_idx = 0;
1443 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1444 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1445 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001446 break;
1447 }
1448 }
1449
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001450 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001451 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1452 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1453 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001454 return skip;
1455 }
1456
Dave Houlton142c4cb2018-10-17 15:04:41 -06001457 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001458 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001459 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1460 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1461 ") must "
1462 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1463 "is set in framebufferNoAttachmentsSampleCounts.",
1464 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001465 }
1466
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001467 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001468 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1469 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1470 ") must "
1471 "be equal to the product of sampleCount (=%" PRIu32
1472 "), the fragment width for shadingRate "
1473 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001474 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001475 }
1476
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001477 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001478 skip |= LogError(
1479 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001480 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1481 ") must "
1482 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001483 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001484 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001485
1486 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001487 // the first width*height*sampleCount bits to all be set. Note: There is no
1488 // guarantee that 64 bits is enough, but practically it's unlikely for an
1489 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001490 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001491 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001492 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001493 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1494 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001495 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1496 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001497 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001498 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001499 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1500 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001501 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001502 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001503 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1504 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001505 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001506 uint32_t idx =
1507 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1508 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001509 }
1510
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001511 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1512 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001513 skip |= LogError(
1514 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001515 "The array pSampleLocations must contain exactly one entry for "
1516 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001517 }
1518
1519 return skip;
1520}
1521
sfricke-samsung51303fb2021-05-09 19:09:13 -07001522bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1523 const VkAllocationCallbacks *pAllocator,
1524 VkPipelineLayout *pPipelineLayout) const {
1525 bool skip = false;
1526 // Validate layout count against device physical limit
1527 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1528 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001529 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1530 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001531 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1532 }
1533
1534 // Validate Push Constant ranges
1535 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1536 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1537 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1538 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1539 // Check that offset + size don't exceed the max.
1540 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1541 if (offset >= max_push_constants_size) {
1542 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001543 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1544 ") that exceeds this "
1545 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001546 i, offset, max_push_constants_size);
1547 }
1548 if (size > max_push_constants_size - offset) {
1549 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001550 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1551 ") and size (%" PRIu32
1552 ") "
1553 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001554 i, offset, size, max_push_constants_size);
1555 }
1556
1557 // size needs to be non-zero and a multiple of 4.
1558 if (size == 0) {
1559 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001560 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1561 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001562 i, size);
1563 }
1564 if (size & 0x3) {
1565 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001566 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1567 ") is not a multiple of 4.",
1568 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001569 }
1570
1571 // offset needs to be a multiple of 4.
1572 if ((offset & 0x3) != 0) {
1573 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001574 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1575 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001576 i, offset);
1577 }
1578 }
1579
1580 // 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.
1581 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1582 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1583 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001584 skip |=
1585 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1586 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001587 }
1588 }
1589 }
1590 return skip;
1591}
1592
ziga-lunargc6341372021-07-28 12:57:42 +02001593bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1594 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1595 bool skip = false;
1596
1597 const auto *required_subgroup_size_features =
1598 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1599
1600 if (required_subgroup_size_features) {
1601 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1602 skip |= LogError(
1603 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1604 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1605 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1606 func_name, msg, pCreateInfo->flags);
1607 }
1608 }
1609
1610 return skip;
1611}
1612
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001613bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1614 uint32_t createInfoCount,
1615 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1616 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001617 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001618 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001619
1620 if (pCreateInfos != nullptr) {
1621 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001622 bool has_dynamic_viewport = false;
1623 bool has_dynamic_scissor = false;
1624 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001625 bool has_dynamic_depth_bias = false;
1626 bool has_dynamic_blend_constant = false;
1627 bool has_dynamic_depth_bounds = false;
1628 bool has_dynamic_stencil_compare = false;
1629 bool has_dynamic_stencil_write = false;
1630 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001631 bool has_dynamic_viewport_w_scaling_nv = false;
1632 bool has_dynamic_discard_rectangle_ext = false;
1633 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001634 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001635 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001636 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001637 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001638 bool has_dynamic_cull_mode = false;
1639 bool has_dynamic_front_face = false;
1640 bool has_dynamic_primitive_topology = false;
1641 bool has_dynamic_viewport_with_count = false;
1642 bool has_dynamic_scissor_with_count = false;
1643 bool has_dynamic_vertex_input_binding_stride = false;
1644 bool has_dynamic_depth_test_enable = false;
1645 bool has_dynamic_depth_write_enable = false;
1646 bool has_dynamic_depth_compare_op = false;
1647 bool has_dynamic_depth_bounds_test_enable = false;
1648 bool has_dynamic_stencil_test_enable = false;
1649 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001650 bool has_patch_control_points = false;
1651 bool has_rasterizer_discard_enable = false;
1652 bool has_depth_bias_enable = false;
1653 bool has_logic_op = false;
1654 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001655 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001656 if (pCreateInfos[i].pDynamicState != nullptr) {
1657 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1658 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1659 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001660 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1661 if (has_dynamic_viewport == true) {
1662 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1663 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001664 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001665 i);
1666 }
1667 has_dynamic_viewport = true;
1668 }
1669 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1670 if (has_dynamic_scissor == true) {
1671 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1672 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001673 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001674 i);
1675 }
1676 has_dynamic_scissor = true;
1677 }
1678 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1679 if (has_dynamic_line_width == true) {
1680 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1681 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001682 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001683 i);
1684 }
1685 has_dynamic_line_width = true;
1686 }
1687 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1688 if (has_dynamic_depth_bias == true) {
1689 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1690 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001691 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001692 i);
1693 }
1694 has_dynamic_depth_bias = true;
1695 }
1696 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1697 if (has_dynamic_blend_constant == true) {
1698 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1699 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001700 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001701 i);
1702 }
1703 has_dynamic_blend_constant = true;
1704 }
1705 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1706 if (has_dynamic_depth_bounds == true) {
1707 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1708 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001709 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001710 i);
1711 }
1712 has_dynamic_depth_bounds = true;
1713 }
1714 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1715 if (has_dynamic_stencil_compare == true) {
1716 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1717 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001718 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001719 i);
1720 }
1721 has_dynamic_stencil_compare = true;
1722 }
1723 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1724 if (has_dynamic_stencil_write == true) {
1725 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1726 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001727 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001728 i);
1729 }
1730 has_dynamic_stencil_write = true;
1731 }
1732 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1733 if (has_dynamic_stencil_reference == true) {
1734 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1735 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001736 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001737 i);
1738 }
1739 has_dynamic_stencil_reference = true;
1740 }
1741 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1742 if (has_dynamic_viewport_w_scaling_nv == true) {
1743 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1744 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001745 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001746 i);
1747 }
1748 has_dynamic_viewport_w_scaling_nv = true;
1749 }
1750 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1751 if (has_dynamic_discard_rectangle_ext == true) {
1752 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1753 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001754 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001755 i);
1756 }
1757 has_dynamic_discard_rectangle_ext = true;
1758 }
1759 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1760 if (has_dynamic_sample_locations_ext == true) {
1761 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1762 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001763 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001764 i);
1765 }
1766 has_dynamic_sample_locations_ext = true;
1767 }
1768 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1769 if (has_dynamic_exclusive_scissor_nv == true) {
1770 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1771 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001772 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001773 i);
1774 }
1775 has_dynamic_exclusive_scissor_nv = true;
1776 }
1777 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1778 if (has_dynamic_shading_rate_palette_nv == true) {
1779 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1780 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001781 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001782 i);
1783 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001784 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001785 }
1786 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1787 if (has_dynamic_viewport_course_sample_order_nv == true) {
1788 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1789 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001790 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001791 i);
1792 }
1793 has_dynamic_viewport_course_sample_order_nv = true;
1794 }
1795 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1796 if (has_dynamic_line_stipple == true) {
1797 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1798 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001799 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001800 i);
1801 }
1802 has_dynamic_line_stipple = true;
1803 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001804 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1805 if (has_dynamic_cull_mode) {
1806 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1807 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001808 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001809 i);
1810 }
1811 has_dynamic_cull_mode = true;
1812 }
1813 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1814 if (has_dynamic_front_face) {
1815 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1816 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001817 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001818 i);
1819 }
1820 has_dynamic_front_face = true;
1821 }
1822 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1823 if (has_dynamic_primitive_topology) {
1824 skip |= LogError(
1825 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1826 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001827 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001828 i);
1829 }
1830 has_dynamic_primitive_topology = true;
1831 }
1832 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1833 if (has_dynamic_viewport_with_count) {
1834 skip |= LogError(
1835 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1836 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001837 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001838 i);
1839 }
1840 has_dynamic_viewport_with_count = true;
1841 }
1842 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1843 if (has_dynamic_scissor_with_count) {
1844 skip |= LogError(
1845 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1846 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001847 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001848 i);
1849 }
1850 has_dynamic_scissor_with_count = true;
1851 }
1852 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1853 if (has_dynamic_vertex_input_binding_stride) {
1854 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1855 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1856 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001857 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001858 i);
1859 }
1860 has_dynamic_vertex_input_binding_stride = true;
1861 }
1862 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1863 if (has_dynamic_depth_test_enable) {
1864 skip |= LogError(
1865 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1866 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001867 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001868 i);
1869 }
1870 has_dynamic_depth_test_enable = true;
1871 }
1872 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1873 if (has_dynamic_depth_write_enable) {
1874 skip |= LogError(
1875 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1876 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001877 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001878 i);
1879 }
1880 has_dynamic_depth_write_enable = true;
1881 }
1882 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1883 if (has_dynamic_depth_compare_op) {
1884 skip |=
1885 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1886 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001887 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001888 i);
1889 }
1890 has_dynamic_depth_compare_op = true;
1891 }
1892 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1893 if (has_dynamic_depth_bounds_test_enable) {
1894 skip |= LogError(
1895 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1896 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001897 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001898 i);
1899 }
1900 has_dynamic_depth_bounds_test_enable = true;
1901 }
1902 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1903 if (has_dynamic_stencil_test_enable) {
1904 skip |= LogError(
1905 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1906 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001907 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001908 i);
1909 }
1910 has_dynamic_stencil_test_enable = true;
1911 }
1912 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1913 if (has_dynamic_stencil_op) {
1914 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1915 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001916 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001917 i);
1918 }
1919 has_dynamic_stencil_op = true;
1920 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001921 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1922 // Not allowed for graphics pipelines
1923 skip |= LogError(
1924 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1925 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001926 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
1927 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001928 i, state_index);
1929 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001930 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1931 if (has_patch_control_points) {
1932 skip |= LogError(
1933 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1934 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001935 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001936 i);
1937 }
1938 has_patch_control_points = true;
1939 }
1940 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1941 if (has_rasterizer_discard_enable) {
1942 skip |= LogError(
1943 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1944 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001945 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001946 i);
1947 }
1948 has_rasterizer_discard_enable = true;
1949 }
1950 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1951 if (has_depth_bias_enable) {
1952 skip |= LogError(
1953 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1954 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001955 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001956 i);
1957 }
1958 has_depth_bias_enable = true;
1959 }
1960 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1961 if (has_logic_op) {
1962 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1963 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001964 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001965 i);
1966 }
1967 has_logic_op = true;
1968 }
1969 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1970 if (has_primitive_restart_enable) {
1971 skip |= LogError(
1972 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1973 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001974 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001975 i);
1976 }
1977 has_primitive_restart_enable = true;
1978 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001979 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1980 if (has_dynamic_vertex_input) {
1981 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001982 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1983 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
1984 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06001985 }
1986 has_dynamic_vertex_input = true;
1987 }
Petr Kraus299ba622017-11-24 03:09:03 +01001988 }
1989 }
1990
sfricke-samsung3b944422021-01-23 02:15:19 -08001991 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1992 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1993 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001994 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
1995 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08001996 i);
1997 }
1998
1999 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2000 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2001 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002002 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002003 i);
2004 }
2005
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002006 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002007 if ((feedback_struct != nullptr) &&
2008 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002009 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
2010 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2011 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2012 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
2013 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002014 }
2015
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002016 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002017
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002018 // Collect active stages and other information
2019 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002020 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002021 bool has_eval = false;
2022 bool has_control = false;
2023 if (pCreateInfos[i].pStages != nullptr) {
2024 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
2025 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
2026
2027 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
2028 has_control = true;
2029 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
2030 has_eval = true;
2031 }
2032
2033 skip |= validate_string(
2034 "vkCreateGraphicsPipelines",
2035 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2036 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002037
2038 std::stringstream msg;
2039 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2040 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2041 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002042 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002043 }
2044
2045 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2046 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2047 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2048 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2049 pCreateInfos[i].pTessellationState,
2050 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2051 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2052
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002053 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002054 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2055
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002056 skip |= validate_struct_pnext(
2057 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2058 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2059 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2060 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2061 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2062 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002063
2064 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2065 pCreateInfos[i].pTessellationState->flags,
2066 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2067 }
2068
2069 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2070 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2071 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2072 pCreateInfos[i].pInputAssemblyState,
2073 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2074 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2075
2076 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2077 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002078 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002079
2080 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2081 pCreateInfos[i].pInputAssemblyState->flags,
2082 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2083
2084 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2085 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2086 pCreateInfos[i].pInputAssemblyState->topology,
2087 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2088
2089 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2090 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2091 }
2092
2093 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002094 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002095
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002096 if (pCreateInfos[i].pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002097 skip |=
2098 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2099 "vkCreateGraphicsPipelines: pararameter "
2100 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2101 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002102 }
2103
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002104 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002105 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2106 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2107 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2108 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002109 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2110 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002111 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002112 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2113 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002114 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002115 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2116 skip |=
2117 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2118 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2119 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2120 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2121 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2122
2123 skip |= validate_array(
2124 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2125 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2126 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2127 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2128
2129 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002130 for (uint32_t vertex_binding_description_index = 0;
2131 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2132 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002133 skip |= validate_ranged_enum(
2134 "vkCreateGraphicsPipelines",
2135 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2136 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002137 pCreateInfos[i]
2138 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2139 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002140 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2141 }
2142 }
2143
2144 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002145 for (uint32_t vertex_attribute_description_index = 0;
2146 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2147 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002148 const VkFormat format =
2149 pCreateInfos[i]
2150 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2151 .format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002152 skip |= validate_ranged_enum(
2153 "vkCreateGraphicsPipelines",
2154 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2155 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002156 pCreateInfos[i]
2157 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2158 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002159 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002160 if (FormatIsDepthOrStencil(format)) {
2161 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2162 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2163 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2164 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002165 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2166 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002167 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2168 "alignment, replace with a color format.",
2169 i, vertex_attribute_description_index, string_VkFormat(format));
2170 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002171 }
2172 }
2173
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002174 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002175 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2176 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002177 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2178 ") is "
2179 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002180 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002181 }
2182
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002183 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002184 skip |=
2185 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2186 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002187 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2188 ") is "
2189 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002190 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002191 }
2192
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002193 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002194 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2195 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002196 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2197 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002198 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2199 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002200 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2201 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002202 "(%" PRIu32 ") is not distinct.",
2203 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002204 }
2205 vertex_bindings.insert(vertex_bind_desc.binding);
2206
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002207 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002208 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2209 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002210 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2211 "].binding (%" PRIu32
2212 ") is "
2213 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002214 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002215 }
2216
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002217 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002218 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2219 "vkCreateGraphicsPipelines: parameter "
2220 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2221 "].stride (%" PRIu32
2222 ") is greater "
2223 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2224 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002225 }
2226 }
2227
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002228 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002229 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2230 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002231 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2232 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002233 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2234 "vkCreateGraphicsPipelines: parameter "
2235 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2236 "].location (%" PRIu32 ") is not distinct.",
2237 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002238 }
2239 attribute_locations.insert(vertex_attrib_desc.location);
2240
2241 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2242 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002243 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2244 "vkCreateGraphicsPipelines: parameter "
2245 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2246 "].binding (%" PRIu32
2247 ") does not exist "
2248 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2249 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002250 }
2251
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002252 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002253 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2254 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002255 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2256 "].location (%" PRIu32
2257 ") is "
2258 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002259 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002260 }
2261
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002262 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002263 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2264 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002265 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2266 "].binding (%" PRIu32
2267 ") is "
2268 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002269 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270 }
2271
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002272 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002273 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2274 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002275 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2276 "].offset (%" PRIu32
2277 ") is "
2278 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002279 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002280 }
2281 }
2282 }
2283
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002284 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2285 if (has_control && has_eval) {
2286 if (pCreateInfos[i].pTessellationState == nullptr) {
2287 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002288 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2289 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002290 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002291 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002292 i, i);
2293 } else {
2294 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2295 skip |= validate_struct_pnext(
2296 "vkCreateGraphicsPipelines",
2297 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2298 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2299 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2300 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002301
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002302 skip |= validate_reserved_flags(
2303 "vkCreateGraphicsPipelines",
2304 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2305 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002306
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002307 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2308 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2309 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2310 "vkCreateGraphicsPipelines: invalid parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002311 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2312 ". patchControlPoints "
2313 "should be >0 and <=%" PRIu32 ".",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002314 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2315 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002316 }
2317 }
2318 }
2319
2320 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2321 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2322 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2323 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002324 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2325 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2326 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2327 "].pViewportState (=NULL) is not a valid pointer.",
2328 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002329 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002330 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2331
2332 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002333 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2334 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2335 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2336 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002337 }
2338
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002339 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002340 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002341 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2342 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002343 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2344 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002345 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002346 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002347 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002348 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002349 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002350 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2351 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002352 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2353 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2354 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002355 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002356
2357 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002358 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002359 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002360 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002361
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002362 auto exclusive_scissor_struct =
2363 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2364 auto shading_rate_image_struct =
2365 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2366 auto coarse_sample_order_struct =
2367 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002368 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002369 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002370 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002371 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002372
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002373 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002374 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002375 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2376 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2377 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2378 ") is not 1.",
2379 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002380 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002381
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002382 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002383 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2384 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2385 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2386 ") is not 1.",
2387 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002388 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002389
Dave Houlton142c4cb2018-10-17 15:04:41 -06002390 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2391 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002392 skip |= LogError(
2393 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2394 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2395 "disabled, but pCreateInfos[%" PRIu32
2396 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2397 ") is not 1.",
2398 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002399 }
2400
Jeff Bolz9af91c52018-09-01 21:53:57 -05002401 if (shading_rate_image_struct &&
2402 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002403 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2404 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2405 "disabled, but pCreateInfos[%" PRIu32
2406 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2407 ") is neither 0 nor 1.",
2408 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002409 }
2410
Petr Krausa6103552017-11-16 21:21:58 +01002411 } else { // multiViewport enabled
2412 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002413 if (!has_dynamic_viewport_with_count) {
2414 skip |= LogError(
2415 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2416 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2417 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002418 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002419 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2420 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2421 "].pViewportState->viewportCount (=%" PRIu32
2422 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2423 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002424 } else if (has_dynamic_viewport_with_count) {
2425 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2426 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2427 "].pViewportState->viewportCount (=%" PRIu32
2428 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2429 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002430 }
Petr Krausa6103552017-11-16 21:21:58 +01002431
2432 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002433 if (!has_dynamic_scissor_with_count) {
2434 skip |= LogError(
2435 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2436 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2437 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002438 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002439 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2440 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2441 "].pViewportState->scissorCount (=%" PRIu32
2442 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2443 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002444 } else if (has_dynamic_scissor_with_count) {
2445 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2446 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2447 "].pViewportState->scissorCount (=%" PRIu32
2448 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2449 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002450 }
2451 }
2452
ziga-lunarg845883b2021-07-14 15:05:00 +02002453 if (!has_dynamic_scissor && viewport_state.pScissors) {
2454 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2455 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002456
2457 if (scissor.offset.x < 0) {
2458 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2459 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2460 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2461 scissor.offset.x, i, scissor_i);
2462 }
2463
2464 if (scissor.offset.y < 0) {
2465 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2466 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2467 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2468 scissor.offset.y, i, scissor_i);
2469 }
2470
ziga-lunarg845883b2021-07-14 15:05:00 +02002471 const int64_t x_sum =
2472 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2473 if (x_sum > std::numeric_limits<int32_t>::max()) {
2474 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2475 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2476 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2477 "] will overflow int32_t.",
2478 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2479 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002480
ziga-lunarg845883b2021-07-14 15:05:00 +02002481 const int64_t y_sum =
2482 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2483 if (y_sum > std::numeric_limits<int32_t>::max()) {
2484 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2485 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2486 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2487 "] will overflow int32_t.",
2488 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2489 }
2490 }
2491 }
2492
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002493 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002494 skip |=
2495 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2496 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2497 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2498 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002499 }
2500
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002501 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002502 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2503 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2504 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2505 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2506 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002507 }
2508
Piers Daniell39842ee2020-07-10 16:42:33 -06002509 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2510 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002511 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2512 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2513 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2514 "].pViewportState->viewportCount (=%" PRIu32 ").",
2515 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002516 }
2517
Dave Houlton142c4cb2018-10-17 15:04:41 -06002518 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002519 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002520 skip |=
2521 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2522 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2523 ") must be zero or identical to pCreateInfos[%" PRIu32
2524 "].pViewportState->viewportCount (=%" PRIu32 ").",
2525 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002526 }
2527
Dave Houlton142c4cb2018-10-17 15:04:41 -06002528 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002529 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002530 skip |= LogError(
2531 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002532 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2533 "] "
2534 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2535 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2536 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002537 }
2538
Petr Krausa6103552017-11-16 21:21:58 +01002539 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002540 skip |= LogError(
2541 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002542 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2543 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002544 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2545 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002546 }
2547
2548 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002549 skip |= LogError(
2550 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002551 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2552 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002553 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2554 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002555 }
2556
Jeff Bolz3e71f782018-08-29 23:15:45 -05002557 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002558 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2559 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2560 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002561 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002562 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2563 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2564 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2565 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002566 }
2567
Jeff Bolz9af91c52018-09-01 21:53:57 -05002568 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002569 shading_rate_image_struct->viewportCount > 0 &&
2570 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002571 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002572 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002573 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002574 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2575 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002576 i, i);
2577 }
2578
Chris Mayer328d8212018-12-11 14:16:18 +01002579 if (vp_swizzle_struct) {
2580 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002581 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2582 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2583 " does "
2584 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2585 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002586 }
2587 }
2588
Petr Krausb3fcdb42018-01-09 22:09:09 +01002589 // validate the VkViewports
2590 if (!has_dynamic_viewport && viewport_state.pViewports) {
2591 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2592 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002593 const char *fn_name = "vkCreateGraphicsPipelines";
2594 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2595 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2596 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002597 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002598 }
2599 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002600
sfricke-samsung45996a42021-09-16 13:45:27 -07002601 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002602 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2603 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2604 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2605 "VK_NV_clip_space_w_scaling extension is not enabled.",
2606 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002607 }
2608
sfricke-samsung45996a42021-09-16 13:45:27 -07002609 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002610 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2611 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2612 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2613 "VK_EXT_discard_rectangles extension is not enabled.",
2614 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002615 }
2616
sfricke-samsung45996a42021-09-16 13:45:27 -07002617 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002618 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2619 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2620 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2621 "VK_EXT_sample_locations extension is not enabled.",
2622 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002623 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002624
sfricke-samsung45996a42021-09-16 13:45:27 -07002625 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002626 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2627 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2628 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2629 "VK_NV_scissor_exclusive extension is not enabled.",
2630 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002631 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002632
2633 if (coarse_sample_order_struct &&
2634 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2635 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002636 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2637 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2638 "] "
2639 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2640 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2641 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002642 }
2643
2644 if (coarse_sample_order_struct) {
2645 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002646 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002647 }
2648 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002649
2650 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2651 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002652 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2653 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2654 "] "
2655 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2656 ") "
2657 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2658 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002659 }
2660 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002661 skip |= LogError(
2662 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002663 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2664 "] "
2665 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2666 i);
2667 }
2668 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002669 }
2670
2671 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002672 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002673 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2674 "].pRasterizationState->rasterizerDiscardEnable "
2675 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002676 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002677 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002678 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002679 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002680 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2681 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002682 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002683 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002684 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002685 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002686 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002687 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002688 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002689 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2690 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002691
2692 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002693 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002694 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002695 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002696
2697 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002698 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002699 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2700 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2701
2702 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002703 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002704 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2705 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002706 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002707 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002709 skip |= validate_flags(
2710 "vkCreateGraphicsPipelines",
2711 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2712 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002713 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002714
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002715 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002716 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002717 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2718 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2719
2720 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002721 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002722 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2723 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2724
2725 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002726 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002727 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2728 "].pMultisampleState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002729 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2730 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002731 }
John Zulauf7acac592017-11-06 11:15:53 -07002732 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002733 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002734 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2735 "vkCreateGraphicsPipelines(): parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002736 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002737 i);
John Zulauf7acac592017-11-06 11:15:53 -07002738 }
2739 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2740 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2741 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002742 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002743
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002744 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2745 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2746 "].pMultisampleState->minSampleShading.",
2747 i);
John Zulauf7acac592017-11-06 11:15:53 -07002748 }
2749 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002750
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002751 const auto *line_state =
2752 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002753
2754 if (line_state) {
2755 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2756 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2757 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2758 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002759 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2760 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002761 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002762 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002763 }
2764 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2765 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002766 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2767 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002768 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002769 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002770 }
2771 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2772 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002773 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2774 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002775 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002776 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002777 }
2778 }
2779 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2780 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2781 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002782 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002783 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
2784 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002785 "range [1,256].",
2786 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002787 }
2788 }
2789 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002790 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002791 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2792 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002793 skip |=
2794 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002795 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2796 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002797 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2798 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002799 }
2800 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2801 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002802 skip |=
2803 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002804 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2805 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002806 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2807 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002808 }
2809 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2810 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002811 skip |=
2812 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002813 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2814 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002815 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2816 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002817 }
2818 if (line_state->stippledLineEnable) {
2819 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2820 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002821 skip |=
2822 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002823 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2824 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002825 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2826 "stippledRectangularLines feature.",
2827 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002828 }
2829 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2830 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002831 skip |=
2832 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002833 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2834 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002835 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2836 "stippledBresenhamLines feature.",
2837 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002838 }
2839 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2840 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002841 skip |=
2842 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002843 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2844 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002845 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2846 "stippledSmoothLines feature.",
2847 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002848 }
2849 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2850 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002851 skip |=
2852 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002853 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2854 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002855 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2856 "stippledRectangularLines and strictLines features.",
2857 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002858 }
2859 }
2860 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002861 }
2862
Petr Krause91f7a12017-12-14 20:57:36 +01002863 bool uses_color_attachment = false;
2864 bool uses_depthstencil_attachment = false;
2865 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002866 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002867 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2868 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002869 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002870 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002871 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002872 }
2873 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002874 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002875 }
Petr Krause91f7a12017-12-14 20:57:36 +01002876 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002877 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002878 }
2879
2880 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002881 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002882 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002883 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002884 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002885 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002886
2887 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002888 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002889 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002890 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002891
2892 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002893 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2895 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2896
2897 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002898 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002899 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2900 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2901
2902 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002903 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002904 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2905 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002906 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002907
2908 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002909 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002910 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2911 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2912
2913 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002914 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002915 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2916 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2917
2918 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002919 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002920 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2921 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002922 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002923
2924 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002925 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002926 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2927 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002928 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002929
2930 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002931 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002932 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2933 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002934 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002935
2936 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002937 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002938 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2939 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002940 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002941
2942 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002943 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2945 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002946 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002947
2948 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002949 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002950 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2951 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002952 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953
2954 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002955 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2957 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002958 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002959
2960 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002961 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2963 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002964 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965
2966 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002967 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002968 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2969 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002970 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2971 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002972 }
2973 }
2974
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002975 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02002976 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
2977 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002978
Petr Krause91f7a12017-12-14 20:57:36 +01002979 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002980 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2981 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2982 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2983 pCreateInfos[i].pColorBlendState,
2984 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2985 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2986
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002988 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002989 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
ziga-lunarg8de09162021-08-05 15:21:33 +02002990 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002991 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2992 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002993 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2994 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995
2996 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002997 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002998 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002999 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000
3001 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003002 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
3004 pCreateInfos[i].pColorBlendState->logicOpEnable);
3005
3006 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003007 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003008 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3009 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00003010 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06003011 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003012
3013 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003014 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
3015 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003016 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003017 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003018 ParameterName::IndexVector{i, attachment_index}),
3019 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003020
3021 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003022 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003023 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003024 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003025 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003026 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003027 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003028
3029 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003030 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003031 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003032 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003033 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003034 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003035 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003036
3037 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003038 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003039 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003040 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003041 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003042 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003043 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003044
3045 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003046 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003047 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003048 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003049 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003050 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003051 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003052
3053 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003054 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003055 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003056 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003057 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003058 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003059 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003060
3061 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003062 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003063 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003064 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003065 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003066 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003067 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003068
3069 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003070 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003071 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003072 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003073 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003074 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003075 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003076
3077 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3078 bool invalid = false;
3079 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3080 case VK_BLEND_OP_ZERO_EXT:
3081 case VK_BLEND_OP_SRC_EXT:
3082 case VK_BLEND_OP_DST_EXT:
3083 case VK_BLEND_OP_SRC_OVER_EXT:
3084 case VK_BLEND_OP_DST_OVER_EXT:
3085 case VK_BLEND_OP_SRC_IN_EXT:
3086 case VK_BLEND_OP_DST_IN_EXT:
3087 case VK_BLEND_OP_SRC_OUT_EXT:
3088 case VK_BLEND_OP_DST_OUT_EXT:
3089 case VK_BLEND_OP_SRC_ATOP_EXT:
3090 case VK_BLEND_OP_DST_ATOP_EXT:
3091 case VK_BLEND_OP_XOR_EXT:
3092 case VK_BLEND_OP_INVERT_EXT:
3093 case VK_BLEND_OP_INVERT_RGB_EXT:
3094 case VK_BLEND_OP_LINEARDODGE_EXT:
3095 case VK_BLEND_OP_LINEARBURN_EXT:
3096 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3097 case VK_BLEND_OP_LINEARLIGHT_EXT:
3098 case VK_BLEND_OP_PINLIGHT_EXT:
3099 case VK_BLEND_OP_HARDMIX_EXT:
3100 case VK_BLEND_OP_PLUS_EXT:
3101 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3102 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3103 case VK_BLEND_OP_PLUS_DARKER_EXT:
3104 case VK_BLEND_OP_MINUS_EXT:
3105 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3106 case VK_BLEND_OP_CONTRAST_EXT:
3107 case VK_BLEND_OP_INVERT_OVG_EXT:
3108 case VK_BLEND_OP_RED_EXT:
3109 case VK_BLEND_OP_GREEN_EXT:
3110 case VK_BLEND_OP_BLUE_EXT:
3111 invalid = true;
3112 break;
3113 default:
3114 break;
3115 }
3116 if (invalid) {
3117 skip |= LogError(
3118 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3119 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3120 "].pColorBlendState->pAttachments[%" PRIu32
3121 "].colorBlendOp (%s) is not valid when "
3122 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3123 "VK_FALSE",
3124 i, attachment_index,
3125 string_VkBlendOp(
3126 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3127 }
3128 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003129 }
3130 }
3131
3132 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003133 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003134 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3135 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003136 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3137 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003138 }
3139
3140 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3141 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3142 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003143 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003144 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003145 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3146 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003147 }
3148 }
3149 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003150
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003151 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3152 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003153 if (pCreateInfos[i].basePipelineIndex != -1) {
3154 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003155 skip |=
3156 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003157 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3158 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003159 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003160 "and pCreateInfos->basePipelineIndex is not -1.",
3161 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003162 }
3163 }
3164
Petr Kraus9752aae2017-11-24 03:05:50 +01003165 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3166 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003167 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003168 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3169 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003170 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003171 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3172 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003173 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003174 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003175 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003176 skip |=
3177 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003178 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3179 ") must be a valid"
3180 "index into the pCreateInfos array, of size %" PRIu32 ".",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003181 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003182 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003183 }
3184 }
3185
Petr Kraus9752aae2017-11-24 03:05:50 +01003186 if (pCreateInfos[i].pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003187 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003188 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3189 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003190 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3191 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3192 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3193 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003194 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3195 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003196 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003197 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003198 "pCreateInfos[%" PRIu32
3199 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003200 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3201 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003202 }
3203 } else {
3204 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3205 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3206 (physical_device_features.fillModeNonSolid == false)) {
3207 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003208 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3209 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003210 "pCreateInfos[%" PRIu32
3211 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003212 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3213 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003214 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003215 }
Petr Kraus299ba622017-11-24 03:09:03 +01003216
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003217 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003218 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003219 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3220 "The line width state is static (pCreateInfos[%" PRIu32
3221 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3222 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3223 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3224 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003225 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003226 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003227
3228 // Validate no flags not allowed are used
3229 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003230 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003231 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3232 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003233 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3234 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003235 }
3236 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003237 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003238 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3239 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003240 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3241 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003242 }
3243 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3244 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003245 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3246 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003247 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3248 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003249 }
3250 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3251 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003252 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3253 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003254 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3255 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003256 }
3257 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3258 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003259 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3260 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003261 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3262 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003263 }
3264 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3265 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003266 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3267 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003268 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3269 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003270 }
3271 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3272 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003273 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3274 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003275 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3276 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003277 }
3278 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3279 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003280 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3281 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003282 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3283 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003284 }
3285 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3286 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003287 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3288 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003289 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3290 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003291 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003292 }
3293 }
3294
3295 return skip;
3296}
3297
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003298bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3299 uint32_t createInfoCount,
3300 const VkComputePipelineCreateInfo *pCreateInfos,
3301 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003302 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003303 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003304 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003305 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003306 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003307 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003308 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003309 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003310 skip |=
3311 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3312 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3313 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3314 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003315 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003316
3317 // Make sure compute stage is selected
3318 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003319 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003320 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3321 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003322 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003323 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003324
sfricke-samsungeb549012021-04-16 01:25:51 -07003325 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3326 // Validate no flags not allowed are used
3327 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003328 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3329 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3330 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3331 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003332 }
3333 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3334 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003335 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3336 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003337 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3338 i, flags);
3339 }
3340 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3341 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003342 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3343 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003344 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3345 i, flags);
3346 }
3347 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3348 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003349 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3350 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003351 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3352 i, flags);
3353 }
3354 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3355 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003356 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3357 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003358 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3359 i, flags);
3360 }
3361 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3362 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003363 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3364 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003365 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3366 i, flags);
3367 }
3368 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3369 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003370 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3371 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003372 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3373 i, flags);
3374 }
3375 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3376 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003377 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3378 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003379 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3380 i, flags);
3381 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003382 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3383 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003384 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3385 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003386 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3387 i, flags);
3388 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003389 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3390 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003391 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3392 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003393 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3394 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003395 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003396 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3397 if (pCreateInfos[i].basePipelineIndex != -1) {
3398 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3399 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3400 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3401 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3402 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3403 i);
3404 }
3405 }
3406
3407 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3408 if (pCreateInfos[i].basePipelineIndex != -1) {
3409 skip |= LogError(
3410 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3411 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3412 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3413 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3414 i);
3415 }
3416 } else {
3417 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3418 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3419 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3420 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3421 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3422 }
3423 }
3424 }
ziga-lunargc6341372021-07-28 12:57:42 +02003425
3426 std::stringstream msg;
3427 msg << "pCreateInfos[%" << i << "].stage";
3428 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003429 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003430 return skip;
3431}
3432
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003433bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003434 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003435 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003436
3437 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003438 const auto &features = physical_device_features;
3439 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003440
John Zulauf71968502017-10-26 13:51:15 -06003441 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3442 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003443 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3444 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3445 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3446 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003447 }
3448
3449 // Anistropy cannot be enabled in sampler unless enabled as a feature
3450 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003451 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3452 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3453 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003454 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003455 }
John Zulauf71968502017-10-26 13:51:15 -06003456
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003457 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3458 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003459 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3460 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3461 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3462 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003463 }
3464 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003465 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3466 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3467 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3468 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003469 }
3470 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003471 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3472 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3473 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3474 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003475 }
3476 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3477 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3478 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3479 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003480 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3481 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3482 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3483 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3484 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3485 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003486 }
3487 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003488 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3489 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3490 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003491 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003492 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003493 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3494 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3495 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003496 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003497 }
3498
3499 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3500 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003501 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3502 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003503 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003504 if (sampler_reduction != nullptr) {
3505 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3506 skip |= LogError(
3507 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3508 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3509 }
3510 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003511 }
3512
3513 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3514 // valid VkBorderColor value
3515 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3516 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3517 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003518 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3519 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003520 }
3521
John Zulauf275805c2017-10-26 15:34:49 -06003522 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003523 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003524 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3525 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003526 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3527 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3528 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003529 }
3530 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003531
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003532 // Check for valid Lod range
3533 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003534 skip |=
3535 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3536 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003537 }
3538
3539 // Check mipLodBias to device limit
3540 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003541 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3542 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3543 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003544 }
3545
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003546 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003547 if (sampler_conversion != nullptr) {
3548 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3549 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3550 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3551 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003552 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003553 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003554 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3555 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3556 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3557 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3558 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3559 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3560 }
3561 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003562
3563 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3564 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3565 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3566 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3567 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3568 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3569 }
3570 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3571 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3572 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3573 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3574 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3575 }
3576 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3577 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3578 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3579 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3580 pCreateInfo->minLod, pCreateInfo->maxLod);
3581 }
3582 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3583 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3584 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3585 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3586 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3587 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3588 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3589 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3590 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3591 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3592 }
3593 if (pCreateInfo->anisotropyEnable) {
3594 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3595 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3596 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3597 }
3598 if (pCreateInfo->compareEnable) {
3599 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3600 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3601 "pCreateInfo->compareEnable must be VK_FALSE");
3602 }
3603 if (pCreateInfo->unnormalizedCoordinates) {
3604 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3605 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3606 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3607 }
3608 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003609 }
3610
Tony-LunarG7337b312020-04-15 16:40:25 -06003611 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3612 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003613 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
Tony-LunarG7337b312020-04-15 16:40:25 -06003614 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3615 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3616 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3617 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003618 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003619 if (!custom_create_info) {
3620 skip |=
3621 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3622 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3623 "struct in pNext chain.\n",
3624 string_VkBorderColor(pCreateInfo->borderColor));
3625 } else {
3626 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3627 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3628 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3629 !FormatIsSampledFloat(custom_create_info->format)))) {
3630 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3631 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3632 "whose type does not match\n",
3633 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3634 ;
3635 }
3636 }
3637 }
3638
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003639 return skip;
3640}
3641
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003642bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3643 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3644 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003645 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003646 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003647
3648 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3649 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3650 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3651 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003652 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3653 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3654 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3655 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3656 ++descriptor_index) {
3657 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003658 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003659 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003660 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
3661 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003662 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003663 }
3664 }
3665 }
3666
3667 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3668 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3669 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003670 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003671 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3672 "].descriptorCount is not 0, "
3673 "pCreateInfo->pBindings[%" PRIu32
3674 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003675 "values.",
3676 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003677 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003678
3679 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3680 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3681 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003682 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3683 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3684 "].descriptorCount is not 0 and "
3685 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
3686 "].stageFlags "
3687 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3688 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003689 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003690 }
3691 }
3692 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003693 return skip;
3694}
3695
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003696bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3697 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003698 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003699 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3700 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3701 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003702 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3703 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003704}
3705
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003706bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3707 const VkWriteDescriptorSet *pDescriptorWrites,
3708 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003709 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003710
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003711 if (pDescriptorWrites != NULL) {
3712 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3713 // descriptorCount must be greater than 0
3714 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003715 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3716 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
3717 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003718 }
3719
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003720 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3721 if (validateDstSet) {
3722 // dstSet must be a valid VkDescriptorSet handle
3723 skip |= validate_required_handle(vkCallingFunction,
3724 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3725 pDescriptorWrites[i].dstSet);
3726 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003727
3728 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3729 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3730 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3731 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3732 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3733 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3734 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003735 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3736 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003737 if (pDescriptorWrites[i].pImageInfo == nullptr) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003738 skip |=
3739 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3740 "%s(): if pDescriptorWrites[%" PRIu32
3741 "].descriptorType is "
3742 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3743 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3744 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
3745 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003746 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3747 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003748 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3749 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003750 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3751 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003752 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003753 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3754 ParameterName::IndexVector{i, descriptor_index}),
3755 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003756 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003757 }
3758 }
3759 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3760 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3761 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3762 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3763 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3764 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3765 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003766 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003767 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003768 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003769 "%s(): if pDescriptorWrites[%" PRIu32
3770 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003771 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3772 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003773 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003774 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003775 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003776 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003777 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003778 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003779 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3780 ++descriptor_index) {
3781 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3782 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3783 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003784 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003785 "%s(): if pDescriptorWrites[%" PRIu32
3786 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003787 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003788 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3789 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003790 }
3791 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003792 }
3793 }
3794 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3795 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003796 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003797 }
3798
3799 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3800 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003801 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003802 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3803 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003804 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003805 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003806 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003807 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003808 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003809 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003810 }
3811 }
3812 }
3813 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3814 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003815 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003816 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3817 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003818 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003819 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003820 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003821 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003822 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003823 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003824 }
3825 }
3826 }
3827 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003828 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3829 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003830 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003831 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003832 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3833 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3834 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3835 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003836 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08003837 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3838 pDescriptorWrites[i].descriptorCount);
3839 }
3840 // further checks only if we have right structtype
3841 if (pnext_struct) {
3842 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3843 skip |= LogError(
3844 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003845 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
3846 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08003847 ".",
3848 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003849 }
sourav parmarbcee7512020-12-28 14:34:49 -08003850 if (pnext_struct->accelerationStructureCount == 0) {
3851 skip |= LogError(device,
3852 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003853 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003854 }
3855 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003856 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003857 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3858 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3859 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3860 skip |= LogError(device,
3861 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3862 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003863 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003864 }
3865 }
3866 }
sourav parmarbcee7512020-12-28 14:34:49 -08003867 }
3868 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003869 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003870 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3871 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3872 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3873 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003874 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08003875 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3876 pDescriptorWrites[i].descriptorCount);
3877 }
3878 // further checks only if we have right structtype
3879 if (pnext_struct) {
3880 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3881 skip |= LogError(
3882 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003883 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
3884 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08003885 ".",
3886 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003887 }
sourav parmarbcee7512020-12-28 14:34:49 -08003888 if (pnext_struct->accelerationStructureCount == 0) {
3889 skip |= LogError(device,
3890 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003891 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003892 }
3893 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003894 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003895 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3896 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3897 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3898 skip |= LogError(device,
3899 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3900 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003901 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003902 }
3903 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003904 }
3905 }
3906 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003907 }
3908 }
3909 return skip;
3910}
3911
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003912bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3913 const VkWriteDescriptorSet *pDescriptorWrites,
3914 uint32_t descriptorCopyCount,
3915 const VkCopyDescriptorSet *pDescriptorCopies) const {
3916 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3917}
3918
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003919bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003920 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003921 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003922 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3923}
3924
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003925bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3926 const VkAllocationCallbacks *pAllocator,
3927 VkRenderPass *pRenderPass) const {
3928 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3929}
3930
Mike Schuchardt2df08912020-12-15 16:28:09 -08003931bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003932 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003933 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003934 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3935}
3936
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003937bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3938 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003939 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003940 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003941
3942 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3943 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3944 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003945 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3946 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003947 return skip;
3948}
3949
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003950bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003951 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003952 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003953
3954 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3955 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003956 bool cb_is_secondary;
3957 {
3958 auto lock = cb_read_lock();
3959 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3960 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003961
Tony-LunarG3c287f62020-12-17 12:39:49 -07003962 if (cb_is_secondary) {
3963 // Implicit VUs
3964 // validate only sType here; pointer has to be validated in core_validation
3965 const bool k_not_required = false;
3966 const char *k_no_vuid = nullptr;
3967 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3968 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003969 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3970 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003971
Tony-LunarG3c287f62020-12-17 12:39:49 -07003972 if (info) {
3973 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003974 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3975 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003976 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003977 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3978 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3979 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3980 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003981
Tony-LunarG3c287f62020-12-17 12:39:49 -07003982 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003983
Tony-LunarG3c287f62020-12-17 12:39:49 -07003984 // Explicit VUs
3985 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003986 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003987 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3988 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3989 cmd_name);
3990 }
3991
3992 if (physical_device_features.inheritedQueries) {
3993 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003994 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3995 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3996 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003997 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003998 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003999 }
4000
4001 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004002 skip |=
4003 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4004 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4005 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4006 } else { // !pipelineStatisticsQuery
4007 skip |=
4008 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4009 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004010 }
4011
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004012 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004013 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004014 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004015 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4016 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4017 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004018 commandBuffer,
4019 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004020 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4021 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4022 }
Petr Kraus139757b2019-08-15 17:19:33 +02004023 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004024
4025 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4026 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4027 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4028 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4029 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4030 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4031 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4032 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4033 }
Petr Kraus139757b2019-08-15 17:19:33 +02004034 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004035 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004036 return skip;
4037}
4038
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004039bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004040 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004041 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004042
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004043 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004044 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004045 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4046 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4047 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004048 }
4049 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004050 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4051 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4052 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004053 }
4054 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004055 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004056 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004057 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4058 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4059 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4060 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004061 }
4062 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004063
4064 if (pViewports) {
4065 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4066 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004067 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004068 skip |= manual_PreCallValidateViewport(
4069 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004070 }
4071 }
4072
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004073 return skip;
4074}
4075
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004076bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004077 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004078 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004079
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004080 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004081 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004082 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4083 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4084 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004085 }
4086 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004087 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4088 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4089 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004090 }
4091 } else { // multiViewport enabled
4092 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004093 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004094 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4095 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4096 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4097 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004098 }
4099 }
4100
Petr Kraus6260f0a2018-02-27 21:15:55 +01004101 if (pScissors) {
4102 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4103 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004104
Petr Kraus6260f0a2018-02-27 21:15:55 +01004105 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004106 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4107 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4108 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004109 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004110
Petr Kraus6260f0a2018-02-27 21:15:55 +01004111 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004112 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4113 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4114 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004115 }
4116
4117 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4118 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004119 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4120 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4121 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4122 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004123 }
4124
4125 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4126 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004127 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4128 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4129 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4130 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004131 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004132 }
4133 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004134
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004135 return skip;
4136}
4137
Jeff Bolz5c801d12019-10-09 10:38:45 -05004138bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004139 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004140
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004141 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004142 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4143 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004144 }
4145
4146 return skip;
4147}
4148
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004149bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004150 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004151 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004152
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004153 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004154 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004155 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4156 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004157 }
4158 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004159 skip |=
4160 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4161 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4162 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004163 }
4164 return skip;
4165}
4166
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004167bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004168 VkDeviceSize offset, uint32_t drawCount,
4169 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004170 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004171 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004172 skip |=
4173 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4174 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4175 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004176 }
4177 if (drawCount > device_limits.maxDrawIndirectCount) {
4178 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004179 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4180 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004181 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004182 }
4183 return skip;
4184}
4185
sfricke-samsungf692b972020-05-02 08:00:45 -07004186bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4187 VkDeviceSize countBufferOffset, bool khr) const {
4188 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004189 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004190 if (offset & 3) {
4191 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004192 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004193 }
4194
4195 if (countBufferOffset & 3) {
4196 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004197 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004198 countBufferOffset);
4199 }
4200 return skip;
4201}
4202
4203bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4204 VkDeviceSize offset, VkBuffer countBuffer,
4205 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4206 uint32_t stride) const {
4207 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4208}
4209
4210bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4211 VkDeviceSize offset, VkBuffer countBuffer,
4212 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4213 uint32_t stride) const {
4214 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4215}
4216
4217bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4218 VkDeviceSize countBufferOffset, bool khr) const {
4219 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004220 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004221 if (offset & 3) {
4222 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004223 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004224 }
4225
4226 if (countBufferOffset & 3) {
4227 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004228 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004229 countBufferOffset);
4230 }
4231 return skip;
4232}
4233
4234bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4235 VkDeviceSize offset, VkBuffer countBuffer,
4236 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4237 uint32_t stride) const {
4238 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4239}
4240
4241bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4242 VkDeviceSize offset, VkBuffer countBuffer,
4243 VkDeviceSize countBufferOffset,
4244 uint32_t maxDrawCount, uint32_t stride) const {
4245 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4246}
4247
Tony-LunarG4490de42021-06-21 15:49:19 -06004248bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4249 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4250 uint32_t firstInstance, uint32_t stride) const {
4251 bool skip = false;
4252 if (stride & 3) {
4253 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4254 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4255 }
4256 if (drawCount && nullptr == pVertexInfo) {
4257 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4258 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4259 "one or more valid instances of VkMultiDrawInfoEXT structures");
4260 }
4261 return skip;
4262}
4263
4264bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4265 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4266 uint32_t instanceCount, uint32_t firstInstance,
4267 uint32_t stride, const int32_t *pVertexOffset) const {
4268 bool skip = false;
4269 if (stride & 3) {
4270 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4271 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4272 }
4273 if (drawCount && nullptr == pIndexInfo) {
4274 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4275 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4276 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4277 }
4278 return skip;
4279}
4280
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004281bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4282 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004283 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004284 bool skip = false;
4285 for (uint32_t rect = 0; rect < rectCount; rect++) {
4286 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004287 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004288 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004289 }
sfricke-samsung10867682020-04-25 02:20:39 -07004290 if (pRects[rect].rect.extent.width == 0) {
4291 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004292 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004293 }
4294 if (pRects[rect].rect.extent.height == 0) {
4295 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004296 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004297 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004298 }
4299 return skip;
4300}
4301
Andrew Fobel3abeb992020-01-20 16:33:22 -05004302bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4303 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4304 VkImageFormatProperties2 *pImageFormatProperties,
4305 const char *apiName) const {
4306 bool skip = false;
4307
4308 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004309 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004310 if (image_stencil_struct != nullptr) {
4311 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4312 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4313 // No flags other than the legal attachment bits may be set
4314 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4315 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004316 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4317 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4318 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4319 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4320 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004321 }
4322 }
4323 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004324 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4325 if (image_drm_format) {
4326 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4327 skip |= LogError(
4328 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4329 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4330 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4331 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4332 }
4333 } else {
4334 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4335 skip |= LogError(
4336 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4337 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4338 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4339 apiName);
4340 }
4341 }
4342 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4343 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4344 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4345 if (!format_list || format_list->viewFormatCount == 0) {
4346 skip |= LogError(
4347 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4348 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4349 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4350 apiName);
4351 }
4352 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004353 }
4354
4355 return skip;
4356}
4357
4358bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4359 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4360 VkImageFormatProperties2 *pImageFormatProperties) const {
4361 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4362 "vkGetPhysicalDeviceImageFormatProperties2");
4363}
4364
4365bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4366 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4367 VkImageFormatProperties2 *pImageFormatProperties) const {
4368 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4369 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4370}
4371
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004372bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4373 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4374 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4375 bool skip = false;
4376
4377 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4378 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4379 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4380 }
4381
4382 return skip;
4383}
4384
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004385bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4386 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4387 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4388 bool skip = false;
4389
4390 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4391 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4392 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4393 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4394 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4395 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4396 }
4397
ziga-lunarg42f884b2021-08-25 16:13:20 +02004398 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004399}
4400
sfricke-samsung3999ef62020-02-09 17:05:59 -08004401bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4402 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4403 bool skip = false;
4404
4405 if (pRegions != nullptr) {
4406 for (uint32_t i = 0; i < regionCount; i++) {
4407 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004408 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004409 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004410 }
4411 }
4412 }
4413 return skip;
4414}
4415
Jeff Leger178b1e52020-10-05 12:22:23 -04004416bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4417 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4418 bool skip = false;
4419
4420 if (pCopyBufferInfo->pRegions != nullptr) {
4421 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4422 if (pCopyBufferInfo->pRegions[i].size == 0) {
4423 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004424 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004425 }
4426 }
4427 }
4428 return skip;
4429}
4430
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004431bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004432 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4433 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004434 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004435
4436 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004437 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4438 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4439 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004440 }
4441
4442 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004443 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4444 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4445 "), must be greater than zero and less than or equal to 65536.",
4446 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004447 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004448 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4449 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4450 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004451 }
4452 return skip;
4453}
4454
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004455bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004456 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004457 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004458
4459 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004460 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4461 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4462 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004463 }
4464
4465 if (size != VK_WHOLE_SIZE) {
4466 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004467 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004468 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4469 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004470 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004471 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4472 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004473 }
4474 }
4475 return skip;
4476}
4477
sfricke-samsunga1d00272021-03-10 21:37:41 -08004478bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004479 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004480
4481 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004482 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4483 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4484 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4485 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004486 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004487 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4488 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4489 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004490 }
4491
4492 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4493 // queueFamilyIndexCount uint32_t values
4494 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004495 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004496 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004497 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004498 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4499 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004500 }
4501 }
4502
Dave Houlton413a6782018-05-22 13:01:54 -06004503 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004504 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004505
sfricke-samsunga1d00272021-03-10 21:37:41 -08004506 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4507 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4508 if (format_list_info) {
4509 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4510 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4511 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4512 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004513 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
4514 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004515 func_name, viewFormatCount);
4516 }
4517
4518 // Using the first format, compare the rest of the formats against it that they are compatible
4519 for (uint32_t i = 1; i < viewFormatCount; i++) {
4520 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4521 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4522 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4523 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004524 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
4525 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004526 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4527 string_VkFormat(format_list_info->pViewFormats[i]));
4528 }
4529 }
4530 }
4531
4532 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4533 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4534 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4535 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4536 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4537 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4538 func_name);
4539 } else {
4540 if (format_list_info == nullptr) {
4541 skip |= LogError(
4542 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4543 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4544 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4545 func_name);
4546 } else if (format_list_info->viewFormatCount == 0) {
4547 skip |= LogError(
4548 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4549 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4550 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4551 func_name);
4552 } else {
4553 bool found_base_format = false;
4554 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4555 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4556 found_base_format = true;
4557 break;
4558 }
4559 }
4560 if (!found_base_format) {
4561 skip |=
4562 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4563 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4564 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4565 "pCreateInfo->imageFormat.",
4566 func_name);
4567 }
4568 }
4569 }
4570 }
4571 }
4572 return skip;
4573}
4574
4575bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4576 const VkAllocationCallbacks *pAllocator,
4577 VkSwapchainKHR *pSwapchain) const {
4578 bool skip = false;
4579 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4580 return skip;
4581}
4582
4583bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4584 const VkSwapchainCreateInfoKHR *pCreateInfos,
4585 const VkAllocationCallbacks *pAllocator,
4586 VkSwapchainKHR *pSwapchains) const {
4587 bool skip = false;
4588 if (pCreateInfos) {
4589 for (uint32_t i = 0; i < swapchainCount; i++) {
4590 std::stringstream func_name;
4591 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4592 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4593 }
4594 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004595 return skip;
4596}
4597
Jeff Bolz5c801d12019-10-09 10:38:45 -05004598bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004599 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004600
4601 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004602 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004603 if (present_regions) {
4604 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004605 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004606 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4607 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004608 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004609 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4610 "extension swapchainCount is %i. These values must be equal.",
4611 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004612 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004613 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004614 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4615 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004616 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4617 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4618 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004619 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004620 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004621 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004622 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004623 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004624 }
4625 }
4626
4627 return skip;
4628}
4629
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004630bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4631 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4632 const VkAllocationCallbacks *pAllocator,
4633 VkDisplayModeKHR *pMode) const {
4634 bool skip = false;
4635
4636 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4637 if (display_mode_parameters.visibleRegion.width == 0) {
4638 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4639 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4640 }
4641 if (display_mode_parameters.visibleRegion.height == 0) {
4642 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4643 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4644 }
4645 if (display_mode_parameters.refreshRate == 0) {
4646 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4647 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4648 }
4649
4650 return skip;
4651}
4652
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004653#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004654bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4655 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4656 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004657 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004658 bool skip = false;
4659
4660 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004661 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4662 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004663 }
4664
4665 return skip;
4666}
4667#endif // VK_USE_PLATFORM_WIN32_KHR
4668
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004669bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004670 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004671 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004672 bool skip = false;
4673
4674 if (pCreateInfo) {
4675 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004676 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4677 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004678 }
4679
4680 if (pCreateInfo->pPoolSizes) {
4681 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4682 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004683 skip |= LogError(
4684 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004685 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004686 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004687 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4688 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004689 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4690 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4691 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4692 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4693 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004694 }
Petr Krausc8655be2017-09-27 18:56:51 +02004695 }
4696 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004697
4698 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4699 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4700 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4701 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4702 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4703 }
Petr Krausc8655be2017-09-27 18:56:51 +02004704 }
4705
4706 return skip;
4707}
4708
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004709bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004710 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004711 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004712
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004713 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004714 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004715 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4716 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4717 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004718 }
4719
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004720 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004721 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004722 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4723 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4724 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004725 }
4726
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004727 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004728 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004729 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4730 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4731 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004732 }
4733
4734 return skip;
4735}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004736
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004737bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004738 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004739 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004740
4741 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004742 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4743 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004744 }
4745 return skip;
4746}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004747
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004748bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4749 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004750 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004751 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004752
4753 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004754 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004755 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004756 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4757 "vkCmdDispatch(): baseGroupX (%" PRIu32
4758 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4759 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004760 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004761 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4762 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4763 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4764 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004765 }
4766
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004767 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004768 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004769 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4770 "vkCmdDispatch(): baseGroupY (%" PRIu32
4771 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4772 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004773 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004774 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4775 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4776 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4777 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004778 }
4779
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004780 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004781 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004782 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4783 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4784 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4785 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004786 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004787 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4788 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4789 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4790 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004791 }
4792
4793 return skip;
4794}
4795
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004796bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4797 VkPipelineBindPoint pipelineBindPoint,
4798 VkPipelineLayout layout, uint32_t set,
4799 uint32_t descriptorWriteCount,
4800 const VkWriteDescriptorSet *pDescriptorWrites) const {
4801 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4802}
4803
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004804bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4805 uint32_t firstExclusiveScissor,
4806 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004807 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004808 bool skip = false;
4809
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004810 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004811 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004812 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004813 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4814 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4815 ") is not 0.",
4816 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004817 }
4818 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004819 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004820 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4821 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4822 ") is not 1.",
4823 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004824 }
4825 } else { // multiViewport enabled
4826 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004827 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004828 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4829 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4830 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4831 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004832 }
4833 }
4834
Jeff Bolz3e71f782018-08-29 23:15:45 -05004835 if (pExclusiveScissors) {
4836 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4837 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4838
4839 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004840 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4841 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4842 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004843 }
4844
4845 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004846 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4847 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4848 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004849 }
4850
4851 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4852 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004853 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4854 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4855 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4856 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004857 }
4858
4859 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4860 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004861 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4862 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4863 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4864 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004865 }
4866 }
4867 }
4868
4869 return skip;
4870}
4871
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004872bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4873 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004874 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004875 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004876 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4877 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4878 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4879 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4880 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4881 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004882 }
4883
4884 return skip;
4885}
4886
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004887bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4888 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004889 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004890 bool skip = false;
4891
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004892 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004893 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004894 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004895 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4896 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4897 ") is not 0.",
4898 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004899 }
4900 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004901 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004902 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4903 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4904 ") is not 1.",
4905 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004906 }
4907 }
4908
Jeff Bolz9af91c52018-09-01 21:53:57 -05004909 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004910 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004911 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4912 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4913 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4914 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004915 }
4916
4917 return skip;
4918}
4919
Jeff Bolz5c801d12019-10-09 10:38:45 -05004920bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4921 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4922 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004923 bool skip = false;
4924
Dave Houlton142c4cb2018-10-17 15:04:41 -06004925 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004926 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4927 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4928 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004929 }
4930
4931 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004932 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004933 }
4934
4935 return skip;
4936}
4937
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004938bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004939 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004940 bool skip = false;
4941
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004942 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004943 skip |= LogError(
4944 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004945 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4946 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004947 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004948 }
4949
4950 return skip;
4951}
4952
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004953bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4954 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004955 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004956 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004957 static const int condition_multiples = 0b0011;
4958 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004959 skip |= LogError(
4960 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004961 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004962 }
Lockee1c22882019-06-10 16:02:54 -06004963 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004964 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4965 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4966 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4967 stride);
Lockee1c22882019-06-10 16:02:54 -06004968 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004969 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004970 skip |= LogError(
4971 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004972 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4973 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004974 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004975 if (drawCount > device_limits.maxDrawIndirectCount) {
4976 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004977 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
4978 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004979 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004980 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004981 return skip;
4982}
4983
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004984bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4985 VkDeviceSize offset, VkBuffer countBuffer,
4986 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004987 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004988 bool skip = false;
4989
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004990 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004991 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4992 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4993 "), is not a multiple of 4.",
4994 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004995 }
4996
4997 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004998 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4999 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5000 "), is not a multiple of 4.",
5001 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005002 }
5003
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005004 return skip;
5005}
5006
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005007bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005008 const VkAllocationCallbacks *pAllocator,
5009 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005010 bool skip = false;
5011
5012 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5013 if (pCreateInfo != nullptr) {
5014 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5015 // VkQueryPipelineStatisticFlagBits values
5016 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5017 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005018 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5019 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5020 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5021 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005022 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005023 if (pCreateInfo->queryCount == 0) {
5024 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5025 "vkCreateQueryPool(): queryCount must be greater than zero.");
5026 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005027 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005028 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005029}
5030
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005031bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5032 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005033 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005034 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5035 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005036}
5037
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005038void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005039 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5040 VkResult result) {
5041 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005042 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005043}
5044
Mike Schuchardt2df08912020-12-15 16:28:09 -08005045void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005046 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5047 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005048 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005049 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005050 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005051}
5052
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005053void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5054 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005055 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005056 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005057 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005058}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005059
Tony-LunarG3c287f62020-12-17 12:39:49 -07005060void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005061 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005062 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
5063 auto lock = cb_write_lock();
5064 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005065 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005066 }
5067 }
5068}
5069
5070void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005071 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005072 auto lock = cb_write_lock();
5073 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5074 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5075 }
5076}
5077
5078void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005079 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005080 auto lock = cb_write_lock();
5081 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5082 if (item->second == commandPool) {
5083 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005084 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005085 ++item;
5086 }
5087 }
5088}
5089
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005090bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005091 const VkAllocationCallbacks *pAllocator,
5092 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005093 bool skip = false;
5094
5095 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005096 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005097 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005098 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5099 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005100 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005101
5102 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005103 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005104 if (flags_info) {
5105 flags = flags_info->flags;
5106 }
5107
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005108 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005109 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005110 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005111 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5112 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005113 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005114 }
5115
5116#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005117 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005118#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005119 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5120 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005121#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005122 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005123#endif
5124
5125 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005126 skip |= LogError(
5127 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005128 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5129 }
5130 if (
5131#ifdef VK_USE_PLATFORM_WIN32_KHR
5132 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5133#endif
5134 (import_memory_fd && import_memory_fd->handleType) ||
5135#ifdef VK_USE_PLATFORM_ANDROID_KHR
5136 (import_memory_ahb && import_memory_ahb->buffer) ||
5137#endif
5138 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005139 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5140 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005141 }
5142 }
5143
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005144 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5145 if (export_memory) {
5146 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5147 if (export_memory_nv) {
5148 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5149 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5150 "VkExportMemoryAllocateInfoNV");
5151 }
5152#ifdef VK_USE_PLATFORM_WIN32_KHR
5153 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5154 if (export_memory_win32_nv) {
5155 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5156 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5157 "VkExportMemoryWin32HandleInfoNV");
5158 }
5159#endif
5160 }
5161
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005162 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005163 VkBool32 capture_replay = false;
5164 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005165 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005166 if (vulkan_12_features) {
5167 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5168 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5169 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005170 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005171 if (bda_features) {
5172 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5173 buffer_device_address = bda_features->bufferDeviceAddress;
5174 }
5175 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005176 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005177 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005178 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005179 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005180 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005181 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005182 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005183 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005184 }
5185 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005186 }
5187 return skip;
5188}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005189
Jason Macnak192fa0e2019-07-26 15:07:16 -07005190bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005191 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005192 bool skip = false;
5193
5194 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5195 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5196 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005197 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005198 } else {
5199 uint32_t vertex_component_size = 0;
5200 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5201 vertex_component_size = 4;
5202 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5203 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5204 vertex_component_size = 2;
5205 }
5206 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005207 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005208 }
5209 }
5210
5211 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5212 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005213 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005214 } else {
5215 uint32_t index_element_size = 0;
5216 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5217 index_element_size = 4;
5218 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5219 index_element_size = 2;
5220 }
5221 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005222 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005223 }
5224 }
5225 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5226 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005227 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005228 }
5229 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005230 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005231 }
5232 }
5233
5234 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005235 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005236 }
5237
5238 return skip;
5239}
5240
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005241bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5242 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005243 bool skip = false;
5244
5245 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005246 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005247 }
5248 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005249 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005250 }
5251
5252 return skip;
5253}
5254
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005255bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5256 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005257 bool skip = false;
5258 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005259 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005260 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005261 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005262 }
5263 return skip;
5264}
5265
5266bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005267 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005268 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005269 bool skip = false;
5270 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005271 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5272 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5273 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005274 }
5275 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005276 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5277 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5278 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005279 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005280 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5281 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5282 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5283 }
Jason Macnak5c954952019-07-09 15:46:12 -07005284 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5285 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005286 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5287 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5288 "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 -07005289 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005290 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005291 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005292 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5293 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005294 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5295 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005296 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005297 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005298 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5299 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5300 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005301 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005302 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005303 uint64_t total_triangle_count = 0;
5304 for (uint32_t i = 0; i < info.geometryCount; i++) {
5305 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005306
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005307 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005308
Jason Macnak5c954952019-07-09 15:46:12 -07005309 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5310 continue;
5311 }
5312 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5313 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005314 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005315 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5316 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5317 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005318 }
5319 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005320 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5321 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5322 for (uint32_t i = 1; i < info.geometryCount; i++) {
5323 const VkGeometryNV &geometry = info.pGeometries[i];
5324 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005325 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005326 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5327 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005328 "info.pGeometries[0].geometryType.",
5329 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005330 }
5331 }
5332 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005333 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5334 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5335 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5336 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5337 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5338 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5339 }
5340 }
5341 skip |=
5342 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005343 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005344 return skip;
5345}
5346
Ricardo Garciaa4935972019-02-21 17:43:18 +01005347bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5348 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005349 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005350 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005351 if (pCreateInfo) {
5352 if ((pCreateInfo->compactedSize != 0) &&
5353 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005354 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5355 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5356 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5357 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005358 }
Jason Macnak5c954952019-07-09 15:46:12 -07005359
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005360 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005361 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005362 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005363 return skip;
5364}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005365
Jeff Bolz5c801d12019-10-09 10:38:45 -05005366bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5367 const VkAccelerationStructureInfoNV *pInfo,
5368 VkBuffer instanceData, VkDeviceSize instanceOffset,
5369 VkBool32 update, VkAccelerationStructureNV dst,
5370 VkAccelerationStructureNV src, VkBuffer scratch,
5371 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005372 bool skip = false;
5373
5374 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005375 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005376 }
5377
5378 return skip;
5379}
5380
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005381bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5382 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5383 VkAccelerationStructureKHR *pAccelerationStructure) const {
5384 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005385 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005386 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005387 if (!acceleration_structure_features ||
5388 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5389 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5390 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5391 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005392 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005393 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5394 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005395 (acceleration_structure_features &&
5396 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005397 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005398 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5399 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5400 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5401 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005402 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005403 if (pCreateInfo->deviceAddress &&
5404 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5405 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5406 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5407 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5408 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005409 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5410 (acceleration_structure_features &&
5411 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5412 skip |= LogError(
5413 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5414 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5415 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5416 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005417 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5418 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005419 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5420 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005421 }
sourav parmar83c31b12020-05-06 12:30:54 -07005422 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005423 return skip;
5424}
5425
Jason Macnak5c954952019-07-09 15:46:12 -07005426bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5427 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005428 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005429 bool skip = false;
5430 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005431 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5432 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005433 }
5434 return skip;
5435}
5436
sourav parmarcd5fb182020-07-17 12:58:44 -07005437bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5438 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5439 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5440 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005441 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005442 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005443 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005444 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005445 }
5446 return skip;
5447}
5448
Peter Chen85366392019-05-14 15:20:11 -04005449bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5450 uint32_t createInfoCount,
5451 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5452 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005453 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005454 bool skip = false;
5455
5456 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005457 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5458 std::stringstream msg;
5459 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5460 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5461 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005462 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005463 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005464 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005465 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5466 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5467 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5468 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005469 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005470
5471 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005472 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005473 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5474 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5475 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5476 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5477 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5478 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5479 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5480 }
5481 }
5482
sourav parmarf4a78252020-04-10 13:04:21 -07005483 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5484 skip |=
5485 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5486 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5487 }
5488 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5489 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5490 skip |=
5491 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5492 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5493 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5494 }
5495 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5496 if (pCreateInfos[i].basePipelineIndex != -1) {
5497 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5498 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5499 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5500 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5501 "and pCreateInfos->basePipelineIndex is not -1.");
5502 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005503 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005504 skip |=
5505 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5506 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5507 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5508 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5509 "that element.");
5510 }
sourav parmarf4a78252020-04-10 13:04:21 -07005511 }
5512 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005513 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005514 skip |=
5515 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5516 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5517 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5518 "commands pCreateInfos parameter.");
5519 }
5520 } else {
5521 if (pCreateInfos[i].basePipelineIndex != -1) {
5522 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5523 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5524 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5525 }
5526 }
5527 }
5528 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5529 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5530 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5531 }
5532 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5533 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5534 "vkCreateRayTracingPipelinesNV: flags must not include "
5535 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5536 }
5537 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5538 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5539 "vkCreateRayTracingPipelinesNV: flags must not include "
5540 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5541 }
5542 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5543 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5544 "vkCreateRayTracingPipelinesNV: flags must not include "
5545 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5546 }
5547 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5548 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5549 "vkCreateRayTracingPipelinesNV: flags must not include "
5550 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5551 }
5552 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5553 skip |= LogError(
5554 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5555 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5556 }
5557 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5558 skip |= LogError(
5559 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5560 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5561 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005562 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5563 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5564 "vkCreateRayTracingPipelinesNV: flags must not include "
5565 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5566 }
5567 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5568 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5569 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5570 }
Peter Chen85366392019-05-14 15:20:11 -04005571 }
5572
5573 return skip;
5574}
5575
sourav parmarcd5fb182020-07-17 12:58:44 -07005576bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5577 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5578 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005579 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005580 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005581 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5582 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5583 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005584 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005585 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005586 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5587 std::stringstream msg;
5588 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5589 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5590 &pCreateInfos[i].pStages[i]);
5591 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005592 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5593 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5594 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5595 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5596 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5597 }
5598 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5599 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5600 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5601 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5602 }
5603 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005604 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005605 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5606 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005607 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5608 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5609 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005610 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5611 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5612 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005613 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005614 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005615 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5616 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5617 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5618 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005619 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005620 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5621 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5622 }
5623 }
sourav parmarf4a78252020-04-10 13:04:21 -07005624 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005625 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5626 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005627 }
5628 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005629 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005630 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005631 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5632 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005633 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005634 }
5635 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5636 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5637 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005638 }
5639 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5640 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5641 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5642 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5643 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5644 skip |= LogError(
5645 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005646 "vkCreateRayTracingPipelinesKHR: If flags includes "
5647 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005648 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5649 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5650 "must not be VK_SHADER_UNUSED_KHR");
5651 }
5652 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5653 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5654 skip |= LogError(
5655 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005656 "vkCreateRayTracingPipelinesKHR: If flags includes "
5657 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005658 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5659 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5660 "element must not be VK_SHADER_UNUSED_KHR");
5661 }
5662 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005663 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5664 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5665 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5666 skip |= LogError(
5667 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5668 "vkCreateRayTracingPipelinesKHR: If "
5669 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5670 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5671 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5672 }
5673 }
sourav parmarf4a78252020-04-10 13:04:21 -07005674 }
5675 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5676 if (pCreateInfos[i].basePipelineIndex != -1) {
5677 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5678 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005679 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005680 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5681 "and pCreateInfos->basePipelineIndex is not -1.");
5682 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005683 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005684 skip |=
5685 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5686 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5687 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5688 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5689 "element.");
5690 }
sourav parmarf4a78252020-04-10 13:04:21 -07005691 }
5692 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005693 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005694 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005695 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005696 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
5697 ") must be a valid into the calling"
5698 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07005699 pCreateInfos[i].basePipelineIndex, createInfoCount);
5700 }
5701 } else {
5702 if (pCreateInfos[i].basePipelineIndex != -1) {
5703 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005704 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005705 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5706 }
5707 }
5708 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005709 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5710 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5711 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5712 "vkCreateRayTracingPipelinesKHR: If flags includes "
5713 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5714 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005715 }
5716 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5717 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5718 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5719 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5720 "pLibraryInfo and pLibraryInterface must be NULL.");
5721 }
5722 if (pCreateInfos[i].pLibraryInfo) {
5723 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5724 if (pCreateInfos[i].stageCount == 0) {
5725 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5726 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5727 "stageCount must not be 0.");
5728 }
5729 if (pCreateInfos[i].groupCount == 0) {
5730 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5731 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5732 "groupCount must not be 0.");
5733 }
5734 } else {
5735 if (pCreateInfos[i].pLibraryInterface == NULL) {
5736 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5737 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5738 "is greater than 0, its "
5739 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005740 }
5741 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005742 }
5743 if (pCreateInfos[i].pLibraryInterface) {
5744 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5745 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5746 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5747 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5748 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5749 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005750 }
5751 if (deferredOperation != VK_NULL_HANDLE) {
5752 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5753 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5754 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5755 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005756 }
5757 }
ziga-lunargdea76582021-09-17 14:38:08 +02005758 if (pCreateInfos[i].pDynamicState) {
5759 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
5760 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
5761 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
5762 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
5763 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
5764 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
5765 }
5766 }
5767 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005768 }
5769
5770 return skip;
5771}
5772
Mike Schuchardt21638df2019-03-16 10:52:02 -07005773#ifdef VK_USE_PLATFORM_WIN32_KHR
5774bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5775 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005776 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005777 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07005778 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005779 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005780 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005781 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005782 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005783 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005784 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005785 skip |=
5786 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005787 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005788 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5789 skip |= validate_struct_type(
5790 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5791 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5792 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5793 if (pSurfaceInfo != NULL) {
5794 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5795 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5796 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5797
5798 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5799 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5800 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5801 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005802 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5803 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005804
5805 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5806 }
5807 return skip;
5808}
5809#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005810
5811bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5812 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005813 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005814 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5815 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005816 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005817 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5818 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5819 }
5820 return skip;
5821}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005822
5823bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005824 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005825 bool skip = false;
5826
5827 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005828 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005829 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005830 }
5831
5832 return skip;
5833}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005834
5835bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005836 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005837 bool skip = false;
5838
5839 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005840 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5841 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005842 }
5843
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005844 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005845 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005846 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5847 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005848 }
5849
5850 return skip;
5851}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005852
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005853bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5854 uint32_t bindingCount, const VkBuffer *pBuffers,
5855 const VkDeviceSize *pOffsets) const {
5856 bool skip = false;
5857 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005858 skip |=
5859 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5860 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
5861 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005862 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5863 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005864 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
5865 ") must be less than "
5866 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005867 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5868 }
5869
Jeff Bolz165818a2020-05-08 11:19:03 -05005870 for (uint32_t i = 0; i < bindingCount; ++i) {
5871 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005872 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005873 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005874 skip |=
5875 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5876 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05005877 } else {
5878 if (pOffsets[i] != 0) {
5879 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005880 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
5881 "] is not 0",
5882 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05005883 }
5884 }
5885 }
5886 }
5887
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005888 return skip;
5889}
5890
Mark Lobodzinski84988402019-09-11 15:27:30 -06005891bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005892 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005893 bool skip = false;
5894 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005895 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5896 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005897 }
5898 return skip;
5899}
5900
5901bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005902 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005903 bool skip = false;
5904 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005905 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5906 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005907 }
5908 return skip;
5909}
Petr Kraus3d720392019-11-13 02:52:39 +01005910
5911bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5912 VkSemaphore semaphore, VkFence fence,
5913 uint32_t *pImageIndex) const {
5914 bool skip = false;
5915
5916 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005917 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5918 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005919 }
5920
5921 return skip;
5922}
5923
5924bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5925 uint32_t *pImageIndex) const {
5926 bool skip = false;
5927
5928 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005929 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5930 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005931 }
5932
5933 return skip;
5934}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005935
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005936bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5937 uint32_t firstBinding, uint32_t bindingCount,
5938 const VkBuffer *pBuffers,
5939 const VkDeviceSize *pOffsets,
5940 const VkDeviceSize *pSizes) const {
5941 bool skip = false;
5942
5943 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5944 for (uint32_t i = 0; i < bindingCount; ++i) {
5945 if (pOffsets[i] & 3) {
5946 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5947 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5948 }
5949 }
5950
5951 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5952 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5953 "%s: The firstBinding(%" PRIu32
5954 ") index is greater than or equal to "
5955 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5956 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5957 }
5958
5959 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5960 skip |=
5961 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5962 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5963 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5964 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5965 }
5966
5967 for (uint32_t i = 0; i < bindingCount; ++i) {
5968 // pSizes is optional and may be nullptr.
5969 if (pSizes != nullptr) {
5970 if (pSizes[i] != VK_WHOLE_SIZE &&
5971 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5972 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5973 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5974 ") is not VK_WHOLE_SIZE and is greater than "
5975 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5976 cmd_name, i, pSizes[i]);
5977 }
5978 }
5979 }
5980
5981 return skip;
5982}
5983
5984bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5985 uint32_t firstCounterBuffer,
5986 uint32_t counterBufferCount,
5987 const VkBuffer *pCounterBuffers,
5988 const VkDeviceSize *pCounterBufferOffsets) const {
5989 bool skip = false;
5990
5991 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5992 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5993 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5994 "%s: The firstCounterBuffer(%" PRIu32
5995 ") index is greater than or equal to "
5996 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5997 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5998 }
5999
6000 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6001 skip |=
6002 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6003 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6004 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6005 cmd_name, firstCounterBuffer, counterBufferCount,
6006 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6007 }
6008
6009 return skip;
6010}
6011
6012bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6013 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6014 const VkBuffer *pCounterBuffers,
6015 const VkDeviceSize *pCounterBufferOffsets) const {
6016 bool skip = false;
6017
6018 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6019 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6020 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6021 "%s: The firstCounterBuffer(%" PRIu32
6022 ") index is greater than or equal to "
6023 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6024 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6025 }
6026
6027 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6028 skip |=
6029 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6030 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6031 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6032 cmd_name, firstCounterBuffer, counterBufferCount,
6033 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6034 }
6035
6036 return skip;
6037}
6038
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006039bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6040 uint32_t firstInstance, VkBuffer counterBuffer,
6041 VkDeviceSize counterBufferOffset,
6042 uint32_t counterOffset, uint32_t vertexStride) const {
6043 bool skip = false;
6044
6045 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006046 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6047 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6048 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6049 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006050 }
6051
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006052 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006053 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006054 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006055 }
6056
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006057 return skip;
6058}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006059
6060bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6061 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6062 const VkAllocationCallbacks *pAllocator,
6063 VkSamplerYcbcrConversion *pYcbcrConversion,
6064 const char *apiName) const {
6065 bool skip = false;
6066
6067 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006068 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006069 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006070 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006071 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6072 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006073 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006074 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006075 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006076
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006077#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006078 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006079 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006080#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006081 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006082#endif
6083
sfricke-samsung1a72f942020-07-25 12:09:18 -07006084 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006085
6086 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006087 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006088 const VkComponentMapping components = pCreateInfo->components;
6089 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6090 if (FormatIsXChromaSubsampled(format) == true) {
6091 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6092 skip |=
6093 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006094 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6095 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006096 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006097 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006098
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006099 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6100 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6101 skip |= LogError(
6102 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6103 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6104 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6105 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6106 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006107
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006108 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6109 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6110 skip |=
6111 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006112 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6113 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006114 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006115 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006116
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006117 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6118 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6119 skip |=
6120 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006121 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6122 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006123 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006124 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006125
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006126 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006127 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6128 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6129 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006130 skip |=
6131 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006132 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6133 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006134 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6135 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006136 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006137 }
6138
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006139 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6140 // Checks same VU multiple ways in order to give a more useful error message
6141 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6142 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6143 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6144 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6145 skip |= LogError(
6146 device, vuid,
6147 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6148 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6149 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6150 string_VkComponentSwizzle(components.b));
6151 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006152
sfricke-samsunged028b02021-09-06 23:14:51 -07006153 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6154 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006155 // 3 = no [a]
6156 // 2 = no [b,a]
6157 // 1 = no [g,b,a]
6158 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006159 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006160
sfricke-samsunged028b02021-09-06 23:14:51 -07006161 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6162 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006163 skip |= LogError(device, vuid,
6164 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6165 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6166 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6167 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006168 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006169 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6170 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6171 skip |= LogError(device, vuid,
6172 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6173 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6174 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6175 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6176 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006177 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006178 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6179 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6180 skip |= LogError(device, vuid,
6181 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6182 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6183 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6184 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6185 string_VkComponentSwizzle(components.b));
6186 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006187 }
6188 }
6189
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006190 return skip;
6191}
6192
6193bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6194 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6195 const VkAllocationCallbacks *pAllocator,
6196 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6197 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6198 "vkCreateSamplerYcbcrConversion");
6199}
6200
6201bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6202 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6203 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6204 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6205 "vkCreateSamplerYcbcrConversionKHR");
6206}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006207
6208bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6209 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6210 bool skip = false;
6211 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6212 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6213
6214 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006215 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6216 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6217 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6218 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6219 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006220 }
6221 return skip;
6222}
sourav parmara96ab1a2020-04-25 16:28:23 -07006223
6224bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006225 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006226 bool skip = false;
6227 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6228 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6229 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6230 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006231 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006232 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6233 skip |= LogError(
6234 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6235 "vkCopyAccelerationStructureToMemoryKHR: The "
6236 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6237 }
6238 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6239 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6240 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6241 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6242 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6243 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006244 return skip;
6245}
6246
6247bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6248 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6249 bool skip = false;
6250 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6251 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6252 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6253 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6254 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006255 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6256 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006257 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006258 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006259 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006260 return skip;
6261}
6262
6263bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6264 const char *api_name) const {
6265 bool skip = false;
6266 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6267 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6268 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6269 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6270 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6271 api_name);
6272 }
6273 return skip;
6274}
6275
6276bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006277 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006278 bool skip = false;
6279 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006280 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006281 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006282 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006283 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6284 "vkCopyAccelerationStructureKHR: The "
6285 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006286 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006287 return skip;
6288}
6289
6290bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6291 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6292 bool skip = false;
6293 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6294 return skip;
6295}
6296
6297bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006298 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006299 bool skip = false;
6300 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006301 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006302 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6303 }
6304 return skip;
6305}
6306
6307bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006308 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006309 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006310 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006311 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006312 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6313 skip |= LogError(
6314 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6315 "vkCopyMemoryToAccelerationStructureKHR: The "
6316 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006317 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006318 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6319 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006320 return skip;
6321}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006322
sourav parmara96ab1a2020-04-25 16:28:23 -07006323bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6324 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6325 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006326 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006327 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6328 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006329 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006330 pInfo->src.deviceAddress);
6331 }
sourav parmar83c31b12020-05-06 12:30:54 -07006332 return skip;
6333}
6334bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6335 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6336 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6337 bool skip = false;
6338 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6339 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6340 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6341 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6342 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6343 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6344 }
6345 return skip;
6346}
6347bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6348 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6349 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6350 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006351 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006352 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6353 skip |= LogError(
6354 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6355 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6356 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6357 }
sourav parmar83c31b12020-05-06 12:30:54 -07006358 if (dataSize < accelerationStructureCount * stride) {
6359 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6360 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006361 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006362 dataSize, accelerationStructureCount, stride);
6363 }
6364 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6365 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6366 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6367 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6368 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6369 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6370 }
6371 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6372 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6373 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6374 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6375 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6376 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6377 stride);
6378 }
6379 }
6380 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6381 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6382 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6383 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6384 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6385 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6386 stride);
6387 }
6388 }
sourav parmar83c31b12020-05-06 12:30:54 -07006389 return skip;
6390}
6391bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6392 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6393 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006394 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006395 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6396 skip |= LogError(
6397 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6398 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6399 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006400 }
6401 return skip;
6402}
6403
6404bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006405 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6406 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6407 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6408 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006409 uint32_t width, uint32_t height, uint32_t depth) const {
6410 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006411 // RayGen
6412 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6413 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6414 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006415 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006416 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6417 0) {
6418 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6419 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6420 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6421 }
6422 // Callable
6423 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6424 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6425 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6426 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006427 }
6428 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6429 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6430 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006431 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6432 }
6433 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6434 0) {
6435 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6436 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6437 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006438 }
6439 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006440 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6441 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6442 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6443 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006444 }
6445 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6446 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006447 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6448 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006449 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006450 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6451 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6452 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6453 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6454 }
sourav parmar83c31b12020-05-06 12:30:54 -07006455 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006456 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6457 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6458 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6459 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006460 }
6461 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6462 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6463 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006464 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6465 }
6466 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6467 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6468 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6469 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6470 }
6471 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6472 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6473 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6474 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6475 }
6476 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6477 skip |=
6478 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6479 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6480 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006481 }
6482
sourav parmarcd5fb182020-07-17 12:58:44 -07006483 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6484 skip |=
6485 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6486 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6487 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6488 }
6489
6490 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6491 skip |=
6492 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6493 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6494 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006495 }
6496 return skip;
6497}
6498
sourav parmarcd5fb182020-07-17 12:58:44 -07006499bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6500 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6501 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6502 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006503 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006504 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006505 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6506 skip |= LogError(
6507 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6508 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6509 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006510 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006511 // RayGen
6512 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6513 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6514 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006515 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006516 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6517 0) {
6518 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6519 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6520 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6521 }
6522 // Callabe
6523 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6524 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6525 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6526 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006527 }
6528 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6529 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006530 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6531 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6532 }
6533 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6534 0) {
6535 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6536 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6537 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006538 }
6539 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006540 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6541 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6542 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6543 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006544 }
6545 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6546 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006547 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6548 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006549 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006550 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6551 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6552 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6553 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6554 }
sourav parmar83c31b12020-05-06 12:30:54 -07006555 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006556 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6557 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6558 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6559 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006560 }
6561 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6562 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006563 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6564 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6565 }
6566 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6567 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6568 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6569 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006570 }
6571
sourav parmarcd5fb182020-07-17 12:58:44 -07006572 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6573 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6574 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006575 }
6576 return skip;
6577}
6578bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6579 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6580 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6581 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6582 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6583 uint32_t width, uint32_t height, uint32_t depth) const {
6584 bool skip = false;
6585 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6586 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6587 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6588 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6589 }
6590 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6591 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6592 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6593 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6594 }
6595 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6596 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6597 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6598 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6599 }
6600
6601 // hitShader
6602 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6603 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6604 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6605 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6606 }
6607 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6608 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6609 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6610 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6611 }
6612 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6613 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6614 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6615 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6616 }
6617
6618 // missShader
6619 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6620 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6621 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6622 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6623 }
6624 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6625 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6626 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6627 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6628 }
6629 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6630 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6631 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6632 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6633 }
6634
6635 // raygenShader
6636 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6637 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6638 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006639 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6640 }
6641 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6642 skip |=
6643 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6644 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6645 }
6646 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6647 skip |=
6648 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6649 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6650 }
6651 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6652 skip |=
6653 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6654 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006655 }
6656 return skip;
6657}
6658
sourav parmar83c31b12020-05-06 12:30:54 -07006659bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006660 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6661 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006662 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006663 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6664 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006665 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6666 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006667 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006668 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6669 }
6670 return skip;
6671}
6672
Piers Daniell39842ee2020-07-10 16:42:33 -06006673bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6674 const VkViewport *pViewports) const {
6675 bool skip = false;
6676
6677 if (!physical_device_features.multiViewport) {
6678 if (viewportCount != 1) {
6679 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6680 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6681 ") is not 1.",
6682 viewportCount);
6683 }
6684 } else { // multiViewport enabled
6685 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6686 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6687 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6688 ") must "
6689 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6690 viewportCount, device_limits.maxViewports);
6691 }
6692 }
6693
6694 if (pViewports) {
6695 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6696 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6697 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6698 skip |= manual_PreCallValidateViewport(
6699 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6700 }
6701 }
6702
6703 return skip;
6704}
6705
6706bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6707 const VkRect2D *pScissors) const {
6708 bool skip = false;
6709
6710 if (!physical_device_features.multiViewport) {
6711 if (scissorCount != 1) {
6712 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6713 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6714 ") must "
6715 "be 1 when the multiViewport feature is disabled.",
6716 scissorCount);
6717 }
6718 } else { // multiViewport enabled
6719 if (scissorCount == 0) {
6720 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6721 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6722 ") must "
6723 "be great than zero.",
6724 scissorCount);
6725 } else if (scissorCount > device_limits.maxViewports) {
6726 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6727 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6728 ") must "
6729 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6730 scissorCount, device_limits.maxViewports);
6731 }
6732 }
6733
6734 if (pScissors) {
6735 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6736 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6737
6738 if (scissor.offset.x < 0) {
6739 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6740 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6741 scissor.offset.x);
6742 }
6743
6744 if (scissor.offset.y < 0) {
6745 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6746 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6747 scissor.offset.y);
6748 }
6749
6750 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6751 if (x_sum > INT32_MAX) {
6752 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6753 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6754 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6755 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6756 }
6757
6758 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6759 if (y_sum > INT32_MAX) {
6760 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6761 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6762 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6763 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6764 }
6765 }
6766 }
6767
6768 return skip;
6769}
6770
6771bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6772 uint32_t bindingCount, const VkBuffer *pBuffers,
6773 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6774 const VkDeviceSize *pStrides) const {
6775 bool skip = false;
6776 if (firstBinding >= device_limits.maxVertexInputBindings) {
6777 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006778 "vkCmdBindVertexBuffers2EXT() firstBinding (%" PRIu32
6779 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06006780 firstBinding, device_limits.maxVertexInputBindings);
6781 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6782 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006783 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6784 ") must be less than "
6785 "maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06006786 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6787 }
6788
6789 for (uint32_t i = 0; i < bindingCount; ++i) {
6790 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006791 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006792 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006793 skip |= LogError(
6794 commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6795 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Piers Daniell39842ee2020-07-10 16:42:33 -06006796 } else {
6797 if (pOffsets[i] != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006798 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6799 "vkCmdBindVertexBuffers2EXT() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6800 "] is not 0",
6801 i, i);
Piers Daniell39842ee2020-07-10 16:42:33 -06006802 }
6803 }
6804 }
6805 if (pStrides) {
6806 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006807 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
6808 "vkCmdBindVertexBuffers2EXT() pStrides[%" PRIu32 "] (%" PRIu64
6809 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
6810 i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06006811 }
6812 }
6813 }
6814
6815 return skip;
6816}
sourav parmarcd5fb182020-07-17 12:58:44 -07006817
6818bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6819 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6820 bool skip = false;
6821 for (uint32_t i = 0; i < infoCount; ++i) {
6822 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6823 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6824 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6825 }
6826 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6827 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6828 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6829 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6830 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6831 api_name);
6832 }
6833 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6834 skip |=
6835 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6836 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6837 }
6838 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6839 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6840 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6841 }
6842 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6843 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6844 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6845 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6846 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6847 api_name);
6848 }
6849 if (pInfos[i].pGeometries) {
6850 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6851 skip |= validate_ranged_enum(
6852 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6853 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6854 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6855 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006856 skip |= validate_struct_type(
6857 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6858 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6859 &(pInfos[i].pGeometries[j].geometry.triangles),
6860 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6861 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6862 skip |= validate_struct_pnext(
6863 api_name,
6864 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6865 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6866 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6867 skip |=
6868 validate_ranged_enum(api_name,
6869 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6870 ParameterName::IndexVector{i, j}),
6871 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6872 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6873 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6874 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6875 &pInfos[i].pGeometries[j].geometry.triangles,
6876 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6877 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6878 skip |= validate_ranged_enum(
6879 api_name,
6880 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6881 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6882 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6883
6884 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6885 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6886 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6887 }
6888 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6889 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6890 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6891 skip |=
6892 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6893 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6894 api_name);
6895 }
6896 }
6897 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6898 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6899 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6900 &pInfos[i].pGeometries[j].geometry.instances,
6901 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6902 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6903 skip |= validate_struct_type(
6904 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6905 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6906 &(pInfos[i].pGeometries[j].geometry.instances),
6907 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6908 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6909 skip |= validate_struct_pnext(
6910 api_name,
6911 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6912 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6913 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6914
6915 skip |= validate_bool32(api_name,
6916 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6917 ParameterName::IndexVector{i, j}),
6918 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6919 }
6920 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6921 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6922 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6923 &pInfos[i].pGeometries[j].geometry.aabbs,
6924 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6925 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6926 skip |= validate_struct_type(
6927 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6928 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6929 &(pInfos[i].pGeometries[j].geometry.aabbs),
6930 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6931 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6932 skip |= validate_struct_pnext(
6933 api_name,
6934 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6935 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6936 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6937 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6938 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6939 "(%s):stride must be less than or equal to 2^32-1", api_name);
6940 }
6941 }
6942 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6943 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6944 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6945 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6946 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6947 api_name);
6948 }
6949 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6950 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6951 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6952 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6953 "of elements of"
6954 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6955 api_name);
6956 }
6957 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6958 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6959 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6960 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6961 api_name);
6962 }
6963 }
6964 }
6965 }
6966 if (pInfos[i].ppGeometries != NULL) {
6967 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6968 skip |= validate_ranged_enum(
6969 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6970 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6971 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6972 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006973 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6974 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6975 &pInfos[i].ppGeometries[j]->geometry.triangles,
6976 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6977 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6978 skip |= validate_struct_type(
6979 api_name,
6980 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6981 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6982 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6983 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6984 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6985 skip |= validate_struct_pnext(
6986 api_name,
6987 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6988 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6989 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6990 skip |= validate_ranged_enum(api_name,
6991 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6992 ParameterName::IndexVector{i, j}),
6993 "VkFormat", AllVkFormatEnums,
6994 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6995 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6996 skip |= validate_ranged_enum(api_name,
6997 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6998 ParameterName::IndexVector{i, j}),
6999 "VkIndexType", AllVkIndexTypeEnums,
7000 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7001 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7002 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7003 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7004 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7005 }
7006 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7007 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7008 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7009 skip |=
7010 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7011 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7012 api_name);
7013 }
7014 }
7015 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7016 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7017 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7018 &pInfos[i].ppGeometries[j]->geometry.instances,
7019 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7020 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7021 skip |= validate_struct_type(
7022 api_name,
7023 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7024 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7025 &(pInfos[i].ppGeometries[j]->geometry.instances),
7026 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7027 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7028 skip |= validate_struct_pnext(
7029 api_name,
7030 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7031 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7032 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7033 skip |= validate_bool32(api_name,
7034 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7035 ParameterName::IndexVector{i, j}),
7036 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7037 }
7038 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7039 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7040 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7041 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7042 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7043 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7044 skip |= validate_struct_type(
7045 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7046 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7047 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7048 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7049 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7050 skip |= validate_struct_pnext(
7051 api_name,
7052 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7053 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7054 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7055 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7056 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7057 "(%s):stride must be less than or equal to 2^32-1", api_name);
7058 }
7059 }
7060 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7061 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7062 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7063 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7064 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7065 api_name);
7066 }
7067 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7068 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7069 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7070 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7071 "of elements of"
7072 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7073 api_name);
7074 }
7075 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7076 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7077 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7078 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7079 api_name);
7080 }
7081 }
7082 }
7083 }
7084 }
7085 return skip;
7086}
7087bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7088 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7089 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7090 bool skip = false;
7091 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7092 for (uint32_t i = 0; i < infoCount; ++i) {
7093 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7094 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7095 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7096 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7097 "scratchData.deviceAddress member must be a multiple of "
7098 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7099 }
7100 for (uint32_t k = 0; k < infoCount; ++k) {
7101 if (i == k) continue;
7102 bool found = false;
7103 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007104 skip |=
7105 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7106 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7107 ") of pInfos must "
7108 "not be "
7109 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7110 ") of pInfos.",
7111 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007112 found = true;
7113 }
7114 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007115 skip |=
7116 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7117 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7118 ") of pInfos must "
7119 "not be "
7120 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7121 ") of pInfos.",
7122 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007123 found = true;
7124 }
7125 if (found) break;
7126 }
7127 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7128 if (pInfos[i].pGeometries) {
7129 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7130 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7131 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7132 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7133 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7134 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7135 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7136 }
7137 } else {
7138 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7139 skip |=
7140 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7141 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7142 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7143 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7144 }
7145 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007146 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007147 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7148 skip |= LogError(
7149 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7150 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7151 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7152 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007153 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7154 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007155 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7156 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7157 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7158 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7159 }
7160 }
7161 } else if (pInfos[i].ppGeometries) {
7162 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7163 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7164 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7165 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7166 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7167 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7168 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7169 }
7170 } else {
7171 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7172 skip |=
7173 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7174 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7175 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7176 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7177 }
7178 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007179 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007180 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7181 skip |= LogError(
7182 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7183 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7184 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7185 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007186 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7187 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007188 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7189 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7190 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7191 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7192 }
7193 }
7194 }
7195 }
7196 }
7197 return skip;
7198}
7199
7200bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7201 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7202 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7203 const uint32_t *const *ppMaxPrimitiveCounts) const {
7204 bool skip = false;
7205 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7206 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007207 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007208 if (!ray_tracing_acceleration_structure_features ||
7209 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7210 skip |= LogError(
7211 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7212 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7213 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7214 }
7215 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007216 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7217 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7218 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7219 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7220 "scratchData.deviceAddress member must be a multiple of "
7221 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7222 }
7223 for (uint32_t k = 0; k < infoCount; ++k) {
7224 if (i == k) continue;
7225 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007226 skip |= LogError(
7227 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7228 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7229 ") "
7230 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7231 "any other element [%" PRIu32 ") of pInfos.",
7232 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007233 break;
7234 }
7235 }
7236 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7237 if (pInfos[i].pGeometries) {
7238 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7239 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7240 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7241 skip |= LogError(
7242 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7243 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7244 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7245 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7246 }
7247 } else {
7248 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7249 skip |= LogError(
7250 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7251 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7252 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7253 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7254 }
7255 }
7256 }
7257 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7258 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7259 skip |= LogError(
7260 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7261 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7262 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7263 }
7264 }
7265 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7266 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7267 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7268 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7269 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7270 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7271 }
7272 }
7273 } else if (pInfos[i].ppGeometries) {
7274 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7275 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7276 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7277 skip |= LogError(
7278 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7279 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7280 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7281 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7282 }
7283 } else {
7284 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7285 skip |= LogError(
7286 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7287 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7288 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7289 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7290 }
7291 }
7292 }
7293 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7294 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7295 skip |= LogError(
7296 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7297 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7298 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7299 }
7300 }
7301 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7302 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7303 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7304 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7305 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7306 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7307 }
7308 }
7309 }
7310 }
7311 }
7312 return skip;
7313}
7314
7315bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7316 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7317 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7318 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7319 bool skip = false;
7320 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7321 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007322 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007323 if (!ray_tracing_acceleration_structure_features ||
7324 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7325 skip |=
7326 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7327 "vkBuildAccelerationStructuresKHR: The "
7328 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7329 }
7330 for (uint32_t i = 0; i < infoCount; ++i) {
7331 for (uint32_t j = 0; j < infoCount; ++j) {
7332 if (i == j) continue;
7333 bool found = false;
7334 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007335 skip |=
7336 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7337 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
7338 ") of pInfos must "
7339 "not be "
7340 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7341 ") of pInfos.",
7342 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007343 found = true;
7344 }
7345 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007346 skip |=
7347 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7348 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
7349 ") of pInfos must "
7350 "not be "
7351 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7352 ") of pInfos.",
7353 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007354 found = true;
7355 }
7356 if (found) break;
7357 }
7358 }
7359 return skip;
7360}
7361
7362bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7363 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7364 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7365 bool skip = false;
7366 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7367 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007368 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7369 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007370 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7371 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7372 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7373 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7374 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7375 }
7376 return skip;
7377}
sfricke-samsungecafb192021-01-17 08:21:14 -08007378
7379bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7380 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7381 const VkAllocationCallbacks *pAllocator,
7382 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7383 bool skip = false;
7384 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7385 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7386 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7387 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7388 }
7389 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007390}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007391
7392bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7393 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7394 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7395 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7396 bool skip = false;
7397 const auto *vertex_input_dynamic_state_features =
7398 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7399 const auto *vertex_attribute_divisor_features =
7400 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7401
7402 // VUID-vkCmdSetVertexInputEXT-None-04790
7403 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7404 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7405 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7406 }
7407
7408 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7409 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7410 skip |=
7411 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7412 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7413 }
7414
7415 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7416 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7417 skip |= LogError(
7418 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7419 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7420 }
7421
7422 // VUID-vkCmdSetVertexInputEXT-binding-04793
7423 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7424 bool binding_found = false;
7425 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7426 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7427 binding_found = true;
7428 break;
7429 }
7430 }
7431 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007432 skip |= LogError(
7433 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7434 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007435 }
7436 }
7437
7438 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7439 if (vertexBindingDescriptionCount > 1) {
7440 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7441 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7442 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7443 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7444 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007445 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
7446 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007447 }
7448 }
7449 }
7450 }
7451
7452 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7453 if (vertexAttributeDescriptionCount > 1) {
7454 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7455 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7456 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7457 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7458 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007459 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
7460 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007461 }
7462 }
7463 }
7464 }
7465
7466 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7467 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7468 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007469 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7470 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7471 "].binding is greater than maxVertexInputBindings",
7472 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007473 }
7474
7475 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7476 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007477 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7478 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7479 "].stride is greater than maxVertexInputBindingStride",
7480 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007481 }
7482
7483 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7484 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7485 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7486 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007487 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7488 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007489 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7490 binding);
7491 }
7492
7493 if (pVertexBindingDescriptions[binding].divisor > 1) {
7494 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7495 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7496 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007497 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7498 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007499 "vertexAttributeInstanceRateDivisor is not enabled",
7500 binding);
7501 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007502 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007503 if (pVertexBindingDescriptions[binding].divisor >
7504 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007505 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
7506 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7507 "].divisor is greater than maxVertexAttribDivisor",
7508 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007509 }
7510
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007511 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007512 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007513 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
7514 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7515 "].divisor is greater than 1 but inputRate "
7516 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7517 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007518 }
7519 }
7520 }
7521 }
7522
7523 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007524 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007525 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007526 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
7527 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7528 "].location is greater than maxVertexInputAttributes",
7529 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007530 }
7531
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007532 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007533 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007534 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
7535 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7536 "].binding is greater than maxVertexInputBindings",
7537 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007538 }
7539
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007540 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007541 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007542 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
7543 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7544 "].offset is greater than maxVertexInputAttributeOffset",
7545 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007546 }
7547
7548 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7549 VkFormatProperties properties;
7550 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7551 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7552 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007553 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7554 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007555 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7556 attribute);
7557 }
7558 }
7559
7560 return skip;
7561}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007562
7563bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7564 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7565 const void *pValues) const {
7566 bool skip = false;
7567 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7568 // Check that offset + size don't exceed the max.
7569 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7570 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007571 skip |=
7572 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7573 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
7574 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007575 }
7576 if (size > max_push_constants_size - offset) {
7577 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007578 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
7579 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07007580 offset, size, max_push_constants_size);
7581 }
7582
7583 // size needs to be non-zero and a multiple of 4.
7584 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007585 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
7586 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007587 }
7588
7589 // offset needs to be a multiple of 4.
7590 if ((offset & 0x3) != 0) {
7591 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007592 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007593 }
7594 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007595}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007596
7597bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7598 uint32_t srcCacheCount,
7599 const VkPipelineCache *pSrcCaches) const {
7600 bool skip = false;
7601 if (pSrcCaches) {
7602 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7603 if (pSrcCaches[index0] == dstCache) {
7604 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7605 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7606 report_data->FormatHandle(dstCache).c_str());
7607 break;
7608 }
7609 }
7610 }
7611 return skip;
7612}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007613
7614bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
7615 VkImageLayout imageLayout, const VkClearColorValue *pColor,
7616 uint32_t rangeCount,
7617 const VkImageSubresourceRange *pRanges) const {
7618 bool skip = false;
7619 if (!pColor) {
7620 skip |=
7621 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
7622 }
7623 return skip;
7624}
7625
7626bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
7627 const VkRenderPassBeginInfo *const rp_begin) const {
7628 bool skip = false;
7629 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
7630 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
7631 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02007632 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007633 func_name, rp_begin->clearValueCount);
7634 }
7635 return skip;
7636}
7637
7638bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7639 VkSubpassContents) const {
7640 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
7641 return skip;
7642}
7643
7644bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
7645 const VkRenderPassBeginInfo *pRenderPassBegin,
7646 const VkSubpassBeginInfo *) const {
7647 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
7648 return skip;
7649}
7650
7651bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7652 const VkSubpassBeginInfo *) const {
7653 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
7654 return skip;
7655}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02007656
7657bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
7658 uint32_t firstDiscardRectangle,
7659 uint32_t discardRectangleCount,
7660 const VkRect2D *pDiscardRectangles) const {
7661 bool skip = false;
7662
7663 if (pDiscardRectangles) {
7664 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
7665 const int64_t x_sum =
7666 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
7667 if (x_sum > std::numeric_limits<int32_t>::max()) {
7668 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
7669 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7670 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7671 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
7672 }
7673
7674 const int64_t y_sum =
7675 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
7676 if (y_sum > std::numeric_limits<int32_t>::max()) {
7677 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
7678 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7679 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7680 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
7681 }
7682 }
7683 }
7684
7685 return skip;
7686}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02007687
7688bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
7689 uint32_t queryCount, size_t dataSize, void *pData,
7690 VkDeviceSize stride, VkQueryResultFlags flags) const {
7691 bool skip = false;
7692
7693 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
7694 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
7695 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
7696 }
7697
7698 return skip;
7699}
ziga-lunargcf340c42021-08-19 00:13:38 +02007700
7701bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
7702 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
7703 bool skip = false;
7704
7705 if ((pConditionalRenderingBegin->offset & 3) != 0) {
7706 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
7707 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
7708 ") is not a multiple of 4.",
7709 pConditionalRenderingBegin->offset);
7710 }
7711
7712 return skip;
7713}