blob: f272dab8f6040102f2615f20ce0f7f907e9cb38c [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
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -060037ReadLockGuard StatelessValidation::ReadLock() { return ReadLockGuard(validation_object_mutex, std::defer_lock); }
38WriteLockGuard StatelessValidation::WriteLock() { return WriteLockGuard(validation_object_mutex, std::defer_lock); }
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070039
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;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -060042static ReadLockGuard CBReadLock() { return ReadLockGuard(secondary_cb_map_mutex); }
43static WriteLockGuard CBWriteLock() { return WriteLockGuard(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 }
Mike Schuchardta9101d32021-11-12 12:24:08 -0800580 if (((queue_create_info.flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) != 0) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700581 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
Mike Schuchardta9101d32021-11-12 12:24:08 -0800582 "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
583 "protectedMemory feature being enabled as well.");
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700584 }
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 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003292 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3293 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3294 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3295 "]->flags (0x%x) must not include "
3296 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3297 i, flags);
3298 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003299 }
3300 }
3301
3302 return skip;
3303}
3304
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003305bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3306 uint32_t createInfoCount,
3307 const VkComputePipelineCreateInfo *pCreateInfos,
3308 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003309 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003310 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003311 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003312 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003313 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003314 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003315 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003316 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003317 skip |=
3318 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3319 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3320 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3321 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003322 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003323
3324 // Make sure compute stage is selected
3325 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003326 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003327 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3328 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003329 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003330 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003331
sfricke-samsungeb549012021-04-16 01:25:51 -07003332 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3333 // Validate no flags not allowed are used
3334 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003335 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3336 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3337 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3338 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003339 }
3340 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3341 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
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_ANY_HIT_SHADERS_BIT_KHR.",
3345 i, flags);
3346 }
3347 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3348 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
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_CLOSEST_HIT_SHADERS_BIT_KHR.",
3352 i, flags);
3353 }
3354 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3355 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
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_MISS_SHADERS_BIT_KHR.",
3359 i, flags);
3360 }
3361 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3362 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
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_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3366 i, flags);
3367 }
3368 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3369 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
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_TRIANGLES_BIT_KHR.",
3373 i, flags);
3374 }
3375 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3376 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
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_SKIP_AABBS_BIT_KHR.",
3380 i, flags);
3381 }
3382 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3383 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003384 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3385 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003386 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3387 i, flags);
3388 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003389 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3390 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003391 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3392 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003393 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3394 i, flags);
3395 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003396 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3397 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003398 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3399 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003400 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3401 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003402 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003403 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3404 if (pCreateInfos[i].basePipelineIndex != -1) {
3405 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3406 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3407 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3408 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3409 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3410 i);
3411 }
3412 }
3413
3414 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3415 if (pCreateInfos[i].basePipelineIndex != -1) {
3416 skip |= LogError(
3417 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3418 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3419 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3420 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3421 i);
3422 }
3423 } else {
3424 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3425 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3426 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3427 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3428 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3429 }
3430 }
3431 }
ziga-lunargc6341372021-07-28 12:57:42 +02003432
3433 std::stringstream msg;
3434 msg << "pCreateInfos[%" << i << "].stage";
3435 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003436 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003437 return skip;
3438}
3439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003440bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003441 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003442 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003443
3444 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003445 const auto &features = physical_device_features;
3446 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003447
John Zulauf71968502017-10-26 13:51:15 -06003448 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3449 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003450 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3451 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3452 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3453 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003454 }
3455
3456 // Anistropy cannot be enabled in sampler unless enabled as a feature
3457 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003458 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3459 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3460 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003461 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003462 }
John Zulauf71968502017-10-26 13:51:15 -06003463
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003464 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3465 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003466 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3467 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3468 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3469 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003470 }
3471 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003472 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3473 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3474 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3475 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003476 }
3477 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003478 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3479 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3480 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3481 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003482 }
3483 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3484 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3485 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3486 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003487 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3488 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3489 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3490 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3491 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3492 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003493 }
3494 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003495 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3496 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3497 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003498 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003499 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003500 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3501 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3502 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003503 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003504 }
3505
3506 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3507 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003508 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3509 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003510 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003511 if (sampler_reduction != nullptr) {
3512 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3513 skip |= LogError(
3514 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3515 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3516 }
3517 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003518 }
3519
3520 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3521 // valid VkBorderColor value
3522 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3523 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3524 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003525 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3526 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003527 }
3528
John Zulauf275805c2017-10-26 15:34:49 -06003529 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003530 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003531 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3532 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003533 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3534 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3535 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003536 }
3537 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003538
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003539 // Check for valid Lod range
3540 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003541 skip |=
3542 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3543 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003544 }
3545
3546 // Check mipLodBias to device limit
3547 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003548 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3549 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3550 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003551 }
3552
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003553 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003554 if (sampler_conversion != nullptr) {
3555 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3556 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3557 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3558 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003559 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003560 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003561 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3562 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3563 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3564 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3565 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3566 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3567 }
3568 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003569
3570 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3571 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3572 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3573 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3574 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3575 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3576 }
3577 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3578 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3579 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3580 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3581 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3582 }
3583 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3584 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3585 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3586 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3587 pCreateInfo->minLod, pCreateInfo->maxLod);
3588 }
3589 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3590 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3591 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3592 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3593 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3594 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3595 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3596 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3597 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3598 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3599 }
3600 if (pCreateInfo->anisotropyEnable) {
3601 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3602 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3603 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3604 }
3605 if (pCreateInfo->compareEnable) {
3606 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3607 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3608 "pCreateInfo->compareEnable must be VK_FALSE");
3609 }
3610 if (pCreateInfo->unnormalizedCoordinates) {
3611 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3612 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3613 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3614 }
3615 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003616 }
3617
Tony-LunarG7337b312020-04-15 16:40:25 -06003618 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3619 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003620 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
Tony-LunarG7337b312020-04-15 16:40:25 -06003621 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3622 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3623 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3624 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003625 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003626 if (!custom_create_info) {
3627 skip |=
3628 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3629 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3630 "struct in pNext chain.\n",
3631 string_VkBorderColor(pCreateInfo->borderColor));
3632 } else {
3633 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3634 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3635 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3636 !FormatIsSampledFloat(custom_create_info->format)))) {
3637 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3638 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3639 "whose type does not match\n",
3640 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3641 ;
3642 }
3643 }
3644 }
3645
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003646 return skip;
3647}
3648
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003649bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
3650 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
3651 const char *func_name) const {
3652 bool skip = false;
3653
3654 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
3655 uint32_t mutable_type_count = 0;
3656 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
3657 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
3658 }
3659 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3660 if (mutable_type_count == 0) {
3661 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
3662 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3663 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
3664 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3665 "].descriptorTypeCount is 0.",
3666 func_name, i, i);
3667 }
3668 } else {
3669 if (mutable_type_count > 0) {
3670 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
3671 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3672 "].descriptorType is %s, but "
3673 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3674 "].descriptorTypeCount is not 0.",
3675 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
3676 }
3677 }
3678 }
3679
3680 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
3681 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
3682 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
3683 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
3684 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
3685 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3686 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
3687 func_name, j, k);
3688 break;
3689 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
3690 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
3691 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3692 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
3693 func_name, j, k);
3694 break;
3695 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
3696 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
3697 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3698 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
3699 func_name, j, k);
3700 break;
3701 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
3702 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
3703 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3704 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
3705 func_name, j, k);
3706 break;
3707 default:
3708 break;
3709 }
3710 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
3711 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
3712 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
3713 skip |=
3714 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
3715 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3716 "].pDescriptorTypes[%" PRIu32
3717 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3718 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
3719 func_name, j, k, j, l,
3720 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
3721 }
3722 }
3723 }
3724 }
3725
3726 return skip;
3727}
3728
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003729bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3730 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3731 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003732 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003733 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003734
ziga-lunargfc6896f2021-10-15 18:46:12 +02003735 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
3736 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
3737 bool mutable_descriptor_type_features_enabled =
3738 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
3739
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003740 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3741 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3742 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3743 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003744 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3745 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3746 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3747 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3748 ++descriptor_index) {
3749 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003750 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003751 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003752 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
3753 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003754 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003755 }
3756 }
3757 }
3758
3759 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3760 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3761 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003762 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003763 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3764 "].descriptorCount is not 0, "
3765 "pCreateInfo->pBindings[%" PRIu32
3766 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003767 "values.",
3768 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003769 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003770
3771 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3772 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3773 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003774 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3775 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3776 "].descriptorCount is not 0 and "
3777 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
3778 "].stageFlags "
3779 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3780 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003781 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02003782
3783 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3784 if (!mutable_descriptor_type) {
3785 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
3786 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3787 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3788 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
3789 i);
3790 }
3791 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
3792 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
3793 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3794 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3795 "pImmutableSamplers is not NULL.",
3796 i);
3797 }
3798 if (!mutable_descriptor_type_features_enabled) {
3799 skip |= LogError(
3800 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
3801 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3802 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3803 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
3804 i);
3805 }
3806 }
3807
3808 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
3809 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3810 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
3811 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
3812 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
3813 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
3814 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003815 }
3816 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003817
3818 if (mutable_descriptor_type) {
3819 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
3820 "vkDescriptorSetLayoutCreateInfo");
3821 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003822 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02003823 if (pCreateInfo) {
3824 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
3825 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
3826 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
3827 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
3828 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
3829 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
3830 }
3831 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
3832 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
3833 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
3834 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
3835 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
3836 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
3837 }
3838 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
3839 !mutable_descriptor_type_features_enabled) {
3840 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
3841 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
3842 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
3843 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
3844 }
3845 }
3846
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003847 return skip;
3848}
3849
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003850bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3851 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003852 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003853 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3854 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3855 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003856 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3857 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003858}
3859
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003860bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3861 const VkWriteDescriptorSet *pDescriptorWrites,
3862 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003863 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003864
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003865 if (pDescriptorWrites != NULL) {
3866 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3867 // descriptorCount must be greater than 0
3868 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003869 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3870 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
3871 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003872 }
3873
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003874 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3875 if (validateDstSet) {
3876 // dstSet must be a valid VkDescriptorSet handle
3877 skip |= validate_required_handle(vkCallingFunction,
3878 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3879 pDescriptorWrites[i].dstSet);
3880 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003881
3882 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3883 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3884 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3885 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3886 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3887 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3888 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003889 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3890 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003891 if (pDescriptorWrites[i].pImageInfo == nullptr) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003892 skip |=
3893 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3894 "%s(): if pDescriptorWrites[%" PRIu32
3895 "].descriptorType is "
3896 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3897 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3898 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
3899 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003900 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3901 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003902 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3903 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003904 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3905 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003906 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003907 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3908 ParameterName::IndexVector{i, descriptor_index}),
3909 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003910 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003911 }
3912 }
3913 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3914 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3915 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3916 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3917 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3918 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3919 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003920 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003921 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003922 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003923 "%s(): if pDescriptorWrites[%" PRIu32
3924 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003925 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3926 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003927 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003928 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003929 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003930 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003931 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003932 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003933 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3934 ++descriptor_index) {
3935 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3936 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3937 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003938 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003939 "%s(): if pDescriptorWrites[%" PRIu32
3940 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003941 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003942 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3943 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003944 }
3945 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003946 }
3947 }
3948 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3949 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003950 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003951 }
3952
3953 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3954 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003955 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003956 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3957 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003958 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003959 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003960 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003961 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003962 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003963 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003964 }
3965 }
3966 }
3967 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3968 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003969 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003970 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3971 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003972 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003973 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003974 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003975 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003976 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003977 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003978 }
3979 }
3980 }
3981 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003982 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3983 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003984 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003985 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003986 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3987 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3988 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3989 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003990 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08003991 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3992 pDescriptorWrites[i].descriptorCount);
3993 }
3994 // further checks only if we have right structtype
3995 if (pnext_struct) {
3996 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3997 skip |= LogError(
3998 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003999 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4000 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004001 ".",
4002 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004003 }
sourav parmarbcee7512020-12-28 14:34:49 -08004004 if (pnext_struct->accelerationStructureCount == 0) {
4005 skip |= LogError(device,
4006 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004007 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004008 }
4009 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004010 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004011 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4012 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4013 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4014 skip |= LogError(device,
4015 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4016 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004017 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004018 }
4019 }
4020 }
sourav parmarbcee7512020-12-28 14:34:49 -08004021 }
4022 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004023 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004024 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4025 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4026 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4027 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004028 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004029 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4030 pDescriptorWrites[i].descriptorCount);
4031 }
4032 // further checks only if we have right structtype
4033 if (pnext_struct) {
4034 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4035 skip |= LogError(
4036 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004037 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4038 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004039 ".",
4040 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004041 }
sourav parmarbcee7512020-12-28 14:34:49 -08004042 if (pnext_struct->accelerationStructureCount == 0) {
4043 skip |= LogError(device,
4044 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004045 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004046 }
4047 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004048 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004049 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4050 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4051 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4052 skip |= LogError(device,
4053 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4054 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004055 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004056 }
4057 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004058 }
4059 }
4060 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004061 }
4062 }
4063 return skip;
4064}
4065
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004066bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4067 const VkWriteDescriptorSet *pDescriptorWrites,
4068 uint32_t descriptorCopyCount,
4069 const VkCopyDescriptorSet *pDescriptorCopies) const {
4070 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
4071}
4072
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004073bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004074 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004075 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004076 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4077}
4078
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004079bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4080 const VkAllocationCallbacks *pAllocator,
4081 VkRenderPass *pRenderPass) const {
4082 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4083}
4084
Mike Schuchardt2df08912020-12-15 16:28:09 -08004085bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004086 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004087 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004088 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4089}
4090
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004091bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4092 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004093 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004094 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004095
4096 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4097 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4098 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004099 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4100 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004101 return skip;
4102}
4103
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004104bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004105 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004106 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004107
4108 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4109 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004110 bool cb_is_secondary;
4111 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004112 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004113 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4114 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004115
Tony-LunarG3c287f62020-12-17 12:39:49 -07004116 if (cb_is_secondary) {
4117 // Implicit VUs
4118 // validate only sType here; pointer has to be validated in core_validation
4119 const bool k_not_required = false;
4120 const char *k_no_vuid = nullptr;
4121 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4122 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004123 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4124 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004125
Tony-LunarG3c287f62020-12-17 12:39:49 -07004126 if (info) {
4127 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004128 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004129 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4130 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004131 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004132 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004133 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4134 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4135 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4136 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004137
Tony-LunarG3c287f62020-12-17 12:39:49 -07004138 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004139
Tony-LunarG3c287f62020-12-17 12:39:49 -07004140 // Explicit VUs
4141 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004142 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004143 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4144 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4145 cmd_name);
4146 }
4147
4148 if (physical_device_features.inheritedQueries) {
4149 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004150 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4151 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4152 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004153 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004154 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004155 }
4156
4157 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004158 skip |=
4159 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4160 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4161 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4162 } else { // !pipelineStatisticsQuery
4163 skip |=
4164 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4165 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004166 }
4167
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004168 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004169 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004170 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004171 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4172 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4173 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004174 commandBuffer,
4175 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004176 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4177 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4178 }
Petr Kraus139757b2019-08-15 17:19:33 +02004179 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004180
4181 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4182 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4183 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4184 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4185 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4186 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4187 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4188 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4189 }
Petr Kraus139757b2019-08-15 17:19:33 +02004190 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004191 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004192 return skip;
4193}
4194
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004195bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004196 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004197 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004198
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004199 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004200 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004201 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4202 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4203 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004204 }
4205 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004206 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4207 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4208 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004209 }
4210 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004211 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004212 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004213 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4214 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4215 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4216 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004217 }
4218 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004219
4220 if (pViewports) {
4221 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4222 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004223 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004224 skip |= manual_PreCallValidateViewport(
4225 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004226 }
4227 }
4228
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004229 return skip;
4230}
4231
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004232bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004233 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004234 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004236 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004237 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004238 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4239 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4240 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004241 }
4242 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004243 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4244 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4245 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004246 }
4247 } else { // multiViewport enabled
4248 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004249 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004250 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4251 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4252 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4253 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004254 }
4255 }
4256
Petr Kraus6260f0a2018-02-27 21:15:55 +01004257 if (pScissors) {
4258 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4259 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004260
Petr Kraus6260f0a2018-02-27 21:15:55 +01004261 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004262 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4263 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4264 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004265 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004266
Petr Kraus6260f0a2018-02-27 21:15:55 +01004267 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004268 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4269 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4270 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004271 }
4272
4273 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4274 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004275 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4276 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4277 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4278 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004279 }
4280
4281 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4282 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004283 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4284 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4285 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4286 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004287 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004288 }
4289 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004290
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004291 return skip;
4292}
4293
Jeff Bolz5c801d12019-10-09 10:38:45 -05004294bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004295 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004296
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004297 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004298 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4299 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004300 }
4301
4302 return skip;
4303}
4304
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004305bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004306 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004307 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004308
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004309 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004310 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004311 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4312 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004313 }
4314 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004315 skip |=
4316 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4317 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4318 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004319 }
4320 return skip;
4321}
4322
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004323bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004324 VkDeviceSize offset, uint32_t drawCount,
4325 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004326 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004327 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004328 skip |=
4329 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4330 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4331 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004332 }
4333 if (drawCount > device_limits.maxDrawIndirectCount) {
4334 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004335 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4336 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004337 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004338 }
4339 return skip;
4340}
4341
sfricke-samsungf692b972020-05-02 08:00:45 -07004342bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4343 VkDeviceSize countBufferOffset, bool khr) const {
4344 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004345 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004346 if (offset & 3) {
4347 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004348 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004349 }
4350
4351 if (countBufferOffset & 3) {
4352 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004353 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004354 countBufferOffset);
4355 }
4356 return skip;
4357}
4358
4359bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4360 VkDeviceSize offset, VkBuffer countBuffer,
4361 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4362 uint32_t stride) const {
4363 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4364}
4365
4366bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4367 VkDeviceSize offset, VkBuffer countBuffer,
4368 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4369 uint32_t stride) const {
4370 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4371}
4372
4373bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4374 VkDeviceSize countBufferOffset, bool khr) const {
4375 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004376 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004377 if (offset & 3) {
4378 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004379 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004380 }
4381
4382 if (countBufferOffset & 3) {
4383 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004384 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004385 countBufferOffset);
4386 }
4387 return skip;
4388}
4389
4390bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4391 VkDeviceSize offset, VkBuffer countBuffer,
4392 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4393 uint32_t stride) const {
4394 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4395}
4396
4397bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4398 VkDeviceSize offset, VkBuffer countBuffer,
4399 VkDeviceSize countBufferOffset,
4400 uint32_t maxDrawCount, uint32_t stride) const {
4401 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4402}
4403
Tony-LunarG4490de42021-06-21 15:49:19 -06004404bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4405 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4406 uint32_t firstInstance, uint32_t stride) const {
4407 bool skip = false;
4408 if (stride & 3) {
4409 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4410 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4411 }
4412 if (drawCount && nullptr == pVertexInfo) {
4413 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4414 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4415 "one or more valid instances of VkMultiDrawInfoEXT structures");
4416 }
4417 return skip;
4418}
4419
4420bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4421 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4422 uint32_t instanceCount, uint32_t firstInstance,
4423 uint32_t stride, const int32_t *pVertexOffset) const {
4424 bool skip = false;
4425 if (stride & 3) {
4426 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4427 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4428 }
4429 if (drawCount && nullptr == pIndexInfo) {
4430 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4431 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4432 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4433 }
4434 return skip;
4435}
4436
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004437bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4438 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004439 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004440 bool skip = false;
4441 for (uint32_t rect = 0; rect < rectCount; rect++) {
4442 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004443 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004444 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004445 }
sfricke-samsung10867682020-04-25 02:20:39 -07004446 if (pRects[rect].rect.extent.width == 0) {
4447 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004448 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004449 }
4450 if (pRects[rect].rect.extent.height == 0) {
4451 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004452 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004453 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004454 }
4455 return skip;
4456}
4457
Andrew Fobel3abeb992020-01-20 16:33:22 -05004458bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4459 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4460 VkImageFormatProperties2 *pImageFormatProperties,
4461 const char *apiName) const {
4462 bool skip = false;
4463
4464 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004465 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004466 if (image_stencil_struct != nullptr) {
4467 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4468 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4469 // No flags other than the legal attachment bits may be set
4470 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4471 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004472 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4473 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4474 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4475 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4476 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004477 }
4478 }
4479 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004480 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4481 if (image_drm_format) {
4482 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4483 skip |= LogError(
4484 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4485 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4486 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4487 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4488 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004489 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4490 skip |= LogError(
4491 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4492 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4493 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4494 apiName, image_drm_format->queueFamilyIndexCount);
4495 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004496 } else {
4497 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4498 skip |= LogError(
4499 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4500 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4501 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4502 apiName);
4503 }
4504 }
4505 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4506 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4507 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4508 if (!format_list || format_list->viewFormatCount == 0) {
4509 skip |= LogError(
4510 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4511 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4512 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4513 apiName);
4514 }
4515 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004516 }
4517
4518 return skip;
4519}
4520
4521bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4522 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4523 VkImageFormatProperties2 *pImageFormatProperties) const {
4524 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4525 "vkGetPhysicalDeviceImageFormatProperties2");
4526}
4527
4528bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4529 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4530 VkImageFormatProperties2 *pImageFormatProperties) const {
4531 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4532 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4533}
4534
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004535bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4536 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4537 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4538 bool skip = false;
4539
4540 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4541 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4542 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4543 }
4544
4545 return skip;
4546}
4547
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004548bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4549 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4550 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4551 bool skip = false;
4552
4553 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4554 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4555 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4556 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4557 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4558 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4559 }
4560
ziga-lunarg42f884b2021-08-25 16:13:20 +02004561 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004562}
4563
sfricke-samsung3999ef62020-02-09 17:05:59 -08004564bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4565 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4566 bool skip = false;
4567
4568 if (pRegions != nullptr) {
4569 for (uint32_t i = 0; i < regionCount; i++) {
4570 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004571 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004572 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004573 }
4574 }
4575 }
4576 return skip;
4577}
4578
Jeff Leger178b1e52020-10-05 12:22:23 -04004579bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4580 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4581 bool skip = false;
4582
4583 if (pCopyBufferInfo->pRegions != nullptr) {
4584 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4585 if (pCopyBufferInfo->pRegions[i].size == 0) {
4586 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004587 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004588 }
4589 }
4590 }
4591 return skip;
4592}
4593
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004594bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004595 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4596 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004597 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004598
4599 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004600 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4601 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4602 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004603 }
4604
4605 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004606 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4607 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4608 "), must be greater than zero and less than or equal to 65536.",
4609 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004610 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004611 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4612 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4613 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004614 }
4615 return skip;
4616}
4617
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004618bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004619 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004620 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004621
4622 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004623 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4624 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4625 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004626 }
4627
4628 if (size != VK_WHOLE_SIZE) {
4629 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004630 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004631 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4632 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004633 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004634 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4635 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004636 }
4637 }
4638 return skip;
4639}
4640
sfricke-samsunga1d00272021-03-10 21:37:41 -08004641bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004642 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004643
4644 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004645 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4646 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4647 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4648 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004649 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004650 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4651 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4652 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004653 }
4654
4655 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4656 // queueFamilyIndexCount uint32_t values
4657 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004658 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004659 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004660 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004661 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4662 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004663 }
4664 }
4665
Dave Houlton413a6782018-05-22 13:01:54 -06004666 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004667 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004668
sfricke-samsunga1d00272021-03-10 21:37:41 -08004669 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4670 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4671 if (format_list_info) {
4672 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4673 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4674 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4675 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004676 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
4677 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004678 func_name, viewFormatCount);
4679 }
4680
4681 // Using the first format, compare the rest of the formats against it that they are compatible
4682 for (uint32_t i = 1; i < viewFormatCount; i++) {
4683 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4684 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4685 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4686 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004687 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
4688 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004689 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4690 string_VkFormat(format_list_info->pViewFormats[i]));
4691 }
4692 }
4693 }
4694
4695 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4696 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4697 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4698 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4699 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4700 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4701 func_name);
4702 } else {
4703 if (format_list_info == nullptr) {
4704 skip |= LogError(
4705 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4706 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4707 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4708 func_name);
4709 } else if (format_list_info->viewFormatCount == 0) {
4710 skip |= LogError(
4711 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4712 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4713 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4714 func_name);
4715 } else {
4716 bool found_base_format = false;
4717 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4718 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4719 found_base_format = true;
4720 break;
4721 }
4722 }
4723 if (!found_base_format) {
4724 skip |=
4725 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4726 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4727 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4728 "pCreateInfo->imageFormat.",
4729 func_name);
4730 }
4731 }
4732 }
4733 }
4734 }
4735 return skip;
4736}
4737
4738bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4739 const VkAllocationCallbacks *pAllocator,
4740 VkSwapchainKHR *pSwapchain) const {
4741 bool skip = false;
4742 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4743 return skip;
4744}
4745
4746bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4747 const VkSwapchainCreateInfoKHR *pCreateInfos,
4748 const VkAllocationCallbacks *pAllocator,
4749 VkSwapchainKHR *pSwapchains) const {
4750 bool skip = false;
4751 if (pCreateInfos) {
4752 for (uint32_t i = 0; i < swapchainCount; i++) {
4753 std::stringstream func_name;
4754 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4755 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4756 }
4757 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004758 return skip;
4759}
4760
Jeff Bolz5c801d12019-10-09 10:38:45 -05004761bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004762 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004763
4764 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004765 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004766 if (present_regions) {
4767 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004768 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004769 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4770 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004771 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004772 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4773 "extension swapchainCount is %i. These values must be equal.",
4774 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004775 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004776 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004777 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4778 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004779 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4780 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4781 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004782 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004783 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004784 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004785 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004786 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004787 }
4788 }
4789
4790 return skip;
4791}
4792
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004793bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4794 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4795 const VkAllocationCallbacks *pAllocator,
4796 VkDisplayModeKHR *pMode) const {
4797 bool skip = false;
4798
4799 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4800 if (display_mode_parameters.visibleRegion.width == 0) {
4801 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4802 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4803 }
4804 if (display_mode_parameters.visibleRegion.height == 0) {
4805 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4806 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4807 }
4808 if (display_mode_parameters.refreshRate == 0) {
4809 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4810 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4811 }
4812
4813 return skip;
4814}
4815
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004816#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004817bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4818 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4819 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004820 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004821 bool skip = false;
4822
4823 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004824 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4825 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004826 }
4827
4828 return skip;
4829}
4830#endif // VK_USE_PLATFORM_WIN32_KHR
4831
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004832static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
4833 bool partial_overlap = false;
4834
4835 static const std::vector<VkDescriptorType> all_descriptor_types = {
4836 VK_DESCRIPTOR_TYPE_SAMPLER,
4837 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4838 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
4839 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
4840 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
4841 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
4842 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
4843 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4844 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
4845 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
4846 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
4847 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
4848 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
4849 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
4850 };
4851
4852 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4853 if (mutable_descriptor_type) {
4854 std::vector<VkDescriptorType> first_types, second_types;
4855 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
4856 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
4857 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
4858 }
4859 } else {
4860 first_types = all_descriptor_types;
4861 }
4862 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
4863 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4864 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
4865 }
4866 } else {
4867 second_types = all_descriptor_types;
4868 }
4869
4870 bool complete_overlap = first_types.size() == second_types.size();
4871 bool disjoint = true;
4872 for (const auto first_type : first_types) {
4873 bool found = false;
4874 for (const auto second_type : second_types) {
4875 if (first_type == second_type) {
4876 found = true;
4877 break;
4878 }
4879 }
4880 if (found) {
4881 disjoint = false;
4882 } else {
4883 complete_overlap = false;
4884 }
4885 if (!disjoint && !complete_overlap) {
4886 partial_overlap = true;
4887 break;
4888 }
4889 }
4890 }
4891
4892 return partial_overlap;
4893}
4894
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004895bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004896 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004897 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004898 bool skip = false;
4899
4900 if (pCreateInfo) {
4901 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004902 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4903 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004904 }
4905
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004906 const auto *mutable_descriptor_type_features =
4907 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4908 bool mutable_descriptor_type_enabled =
4909 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4910
Petr Krausc8655be2017-09-27 18:56:51 +02004911 if (pCreateInfo->pPoolSizes) {
4912 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4913 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004914 skip |= LogError(
4915 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004916 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004917 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004918 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4919 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004920 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4921 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4922 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4923 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4924 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004925 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004926 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
4927 skip |=
4928 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
4929 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4930 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
4931 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
4932 i);
4933 }
4934 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4935 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
4936 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4937 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
4938 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
4939 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4940 "].type and pCreateInfo->pPoolSizes[%" PRIu32
4941 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
4942 " and have sets which partially overlap.",
4943 i, j);
4944 }
4945 }
4946 }
4947 }
Petr Krausc8655be2017-09-27 18:56:51 +02004948 }
4949 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004950
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004951 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
4952 skip |=
4953 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
4954 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
4955 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
4956 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004957 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4958 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4959 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4960 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4961 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4962 }
Petr Krausc8655be2017-09-27 18:56:51 +02004963 }
4964
4965 return skip;
4966}
4967
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004968bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004969 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004970 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004971
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004972 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004973 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004974 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4975 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4976 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004977 }
4978
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004979 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004980 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004981 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4982 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4983 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004984 }
4985
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004986 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004987 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004988 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4989 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4990 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004991 }
4992
4993 return skip;
4994}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004995
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004996bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004997 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004998 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004999
5000 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005001 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5002 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005003 }
5004 return skip;
5005}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005006
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005007bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5008 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005009 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005010 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005011
5012 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005013 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005014 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005015 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5016 "vkCmdDispatch(): baseGroupX (%" PRIu32
5017 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5018 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005019 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005020 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5021 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5022 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5023 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005024 }
5025
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005026 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005027 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005028 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5029 "vkCmdDispatch(): baseGroupY (%" PRIu32
5030 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5031 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005032 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005033 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5034 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5035 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5036 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005037 }
5038
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005039 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005040 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005041 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5042 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5043 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5044 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005045 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005046 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5047 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5048 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5049 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005050 }
5051
5052 return skip;
5053}
5054
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005055bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5056 VkPipelineBindPoint pipelineBindPoint,
5057 VkPipelineLayout layout, uint32_t set,
5058 uint32_t descriptorWriteCount,
5059 const VkWriteDescriptorSet *pDescriptorWrites) const {
5060 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
5061}
5062
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005063bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5064 uint32_t firstExclusiveScissor,
5065 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005066 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005067 bool skip = false;
5068
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005069 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005070 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005071 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005072 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5073 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5074 ") is not 0.",
5075 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005076 }
5077 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005078 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005079 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5080 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5081 ") is not 1.",
5082 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005083 }
5084 } else { // multiViewport enabled
5085 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005086 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005087 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5088 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5089 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5090 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005091 }
5092 }
5093
Jeff Bolz3e71f782018-08-29 23:15:45 -05005094 if (pExclusiveScissors) {
5095 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5096 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5097
5098 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005099 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5100 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5101 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005102 }
5103
5104 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005105 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5106 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5107 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005108 }
5109
5110 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5111 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005112 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5113 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5114 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5115 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005116 }
5117
5118 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5119 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005120 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5121 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5122 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5123 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005124 }
5125 }
5126 }
5127
5128 return skip;
5129}
5130
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005131bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5132 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005133 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005134 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005135 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5136 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5137 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5138 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5139 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5140 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005141 }
5142
5143 return skip;
5144}
5145
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005146bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5147 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005148 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005149 bool skip = false;
5150
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005151 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005152 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005153 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005154 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5155 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5156 ") is not 0.",
5157 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005158 }
5159 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005160 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005161 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5162 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5163 ") is not 1.",
5164 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005165 }
5166 }
5167
Jeff Bolz9af91c52018-09-01 21:53:57 -05005168 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005169 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005170 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5171 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5172 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5173 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005174 }
5175
5176 return skip;
5177}
5178
Jeff Bolz5c801d12019-10-09 10:38:45 -05005179bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5180 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5181 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005182 bool skip = false;
5183
Dave Houlton142c4cb2018-10-17 15:04:41 -06005184 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005185 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5186 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5187 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005188 }
5189
5190 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005191 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005192 }
5193
5194 return skip;
5195}
5196
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005197bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005198 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005199 bool skip = false;
5200
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005201 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005202 skip |= LogError(
5203 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005204 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5205 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005206 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005207 }
5208
5209 return skip;
5210}
5211
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005212bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5213 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005214 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005215 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005216 static const int condition_multiples = 0b0011;
5217 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005218 skip |= LogError(
5219 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005220 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005221 }
Lockee1c22882019-06-10 16:02:54 -06005222 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005223 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5224 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5225 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5226 stride);
Lockee1c22882019-06-10 16:02:54 -06005227 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005228 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005229 skip |= LogError(
5230 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005231 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5232 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005233 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005234 if (drawCount > device_limits.maxDrawIndirectCount) {
5235 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005236 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5237 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005238 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005239 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005240 return skip;
5241}
5242
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005243bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5244 VkDeviceSize offset, VkBuffer countBuffer,
5245 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005246 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005247 bool skip = false;
5248
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005249 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005250 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5251 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5252 "), is not a multiple of 4.",
5253 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005254 }
5255
5256 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005257 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5258 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5259 "), is not a multiple of 4.",
5260 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005261 }
5262
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005263 return skip;
5264}
5265
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005266bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005267 const VkAllocationCallbacks *pAllocator,
5268 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005269 bool skip = false;
5270
5271 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5272 if (pCreateInfo != nullptr) {
5273 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5274 // VkQueryPipelineStatisticFlagBits values
5275 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5276 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005277 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5278 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5279 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5280 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005281 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005282 if (pCreateInfo->queryCount == 0) {
5283 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5284 "vkCreateQueryPool(): queryCount must be greater than zero.");
5285 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005286 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005287 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005288}
5289
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005290bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5291 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005292 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005293 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5294 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005295}
5296
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005297void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005298 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5299 VkResult result) {
5300 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005301 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005302}
5303
Mike Schuchardt2df08912020-12-15 16:28:09 -08005304void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005305 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5306 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005307 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005308 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005309 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005310}
5311
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005312void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5313 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005314 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005315 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005316 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005317}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005318
Tony-LunarG3c287f62020-12-17 12:39:49 -07005319void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005320 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005321 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005322 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005323 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005324 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005325 }
5326 }
5327}
5328
5329void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005330 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005331 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005332 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5333 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5334 }
5335}
5336
5337void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005338 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005339 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005340 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5341 if (item->second == commandPool) {
5342 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005343 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005344 ++item;
5345 }
5346 }
5347}
5348
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005349bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005350 const VkAllocationCallbacks *pAllocator,
5351 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005352 bool skip = false;
5353
5354 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005355 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005356 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005357 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5358 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005359 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005360
5361 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005362 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005363 if (flags_info) {
5364 flags = flags_info->flags;
5365 }
5366
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005367 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005368 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005369 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005370 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5371 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005372 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005373 }
5374
5375#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005376 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005377#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005378 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5379 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005380#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005381 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005382#endif
5383
5384 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005385 skip |= LogError(
5386 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005387 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5388 }
5389 if (
5390#ifdef VK_USE_PLATFORM_WIN32_KHR
5391 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5392#endif
5393 (import_memory_fd && import_memory_fd->handleType) ||
5394#ifdef VK_USE_PLATFORM_ANDROID_KHR
5395 (import_memory_ahb && import_memory_ahb->buffer) ||
5396#endif
5397 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005398 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5399 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005400 }
5401 }
5402
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005403 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5404 if (export_memory) {
5405 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5406 if (export_memory_nv) {
5407 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5408 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5409 "VkExportMemoryAllocateInfoNV");
5410 }
5411#ifdef VK_USE_PLATFORM_WIN32_KHR
5412 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5413 if (export_memory_win32_nv) {
5414 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5415 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5416 "VkExportMemoryWin32HandleInfoNV");
5417 }
5418#endif
5419 }
5420
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005421 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005422 VkBool32 capture_replay = false;
5423 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005424 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005425 if (vulkan_12_features) {
5426 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5427 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5428 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005429 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005430 if (bda_features) {
5431 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5432 buffer_device_address = bda_features->bufferDeviceAddress;
5433 }
5434 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005435 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005436 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005437 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005438 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005439 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005440 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005441 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005442 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005443 }
5444 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005445 }
5446 return skip;
5447}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005448
Jason Macnak192fa0e2019-07-26 15:07:16 -07005449bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005450 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005451 bool skip = false;
5452
5453 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5454 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5455 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005456 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005457 } else {
5458 uint32_t vertex_component_size = 0;
5459 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5460 vertex_component_size = 4;
5461 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5462 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5463 vertex_component_size = 2;
5464 }
5465 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005466 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005467 }
5468 }
5469
5470 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5471 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005472 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005473 } else {
5474 uint32_t index_element_size = 0;
5475 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5476 index_element_size = 4;
5477 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5478 index_element_size = 2;
5479 }
5480 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005481 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005482 }
5483 }
5484 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5485 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005486 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005487 }
5488 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005489 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005490 }
5491 }
5492
5493 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005494 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005495 }
5496
5497 return skip;
5498}
5499
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005500bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5501 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005502 bool skip = false;
5503
5504 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005505 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005506 }
5507 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005508 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005509 }
5510
5511 return skip;
5512}
5513
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005514bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5515 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005516 bool skip = false;
5517 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005518 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005519 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005520 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005521 }
5522 return skip;
5523}
5524
5525bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005526 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005527 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005528 bool skip = false;
5529 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005530 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5531 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5532 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005533 }
5534 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005535 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5536 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5537 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005538 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005539 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5540 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5541 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5542 }
Jason Macnak5c954952019-07-09 15:46:12 -07005543 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5544 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005545 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5546 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5547 "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 -07005548 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005549 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005550 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005551 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5552 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005553 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5554 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005555 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005556 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005557 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5558 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5559 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005560 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005561 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005562 uint64_t total_triangle_count = 0;
5563 for (uint32_t i = 0; i < info.geometryCount; i++) {
5564 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005565
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005566 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005567
Jason Macnak5c954952019-07-09 15:46:12 -07005568 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5569 continue;
5570 }
5571 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5572 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005573 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005574 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5575 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5576 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005577 }
5578 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005579 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5580 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5581 for (uint32_t i = 1; i < info.geometryCount; i++) {
5582 const VkGeometryNV &geometry = info.pGeometries[i];
5583 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005584 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005585 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5586 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005587 "info.pGeometries[0].geometryType.",
5588 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005589 }
5590 }
5591 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005592 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5593 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5594 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5595 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5596 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5597 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5598 }
5599 }
5600 skip |=
5601 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005602 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005603 return skip;
5604}
5605
Ricardo Garciaa4935972019-02-21 17:43:18 +01005606bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5607 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005608 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005609 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005610 if (pCreateInfo) {
5611 if ((pCreateInfo->compactedSize != 0) &&
5612 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005613 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5614 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5615 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5616 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005617 }
Jason Macnak5c954952019-07-09 15:46:12 -07005618
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005619 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005620 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005621 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005622 return skip;
5623}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005624
Jeff Bolz5c801d12019-10-09 10:38:45 -05005625bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5626 const VkAccelerationStructureInfoNV *pInfo,
5627 VkBuffer instanceData, VkDeviceSize instanceOffset,
5628 VkBool32 update, VkAccelerationStructureNV dst,
5629 VkAccelerationStructureNV src, VkBuffer scratch,
5630 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005631 bool skip = false;
5632
5633 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005634 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005635 }
5636
5637 return skip;
5638}
5639
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005640bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5641 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5642 VkAccelerationStructureKHR *pAccelerationStructure) const {
5643 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005644 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005645 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005646 if (!acceleration_structure_features ||
5647 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5648 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5649 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5650 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005651 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005652 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5653 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005654 (acceleration_structure_features &&
5655 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005656 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005657 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5658 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5659 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5660 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005661 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005662 if (pCreateInfo->deviceAddress &&
5663 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5664 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5665 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5666 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5667 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005668 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5669 (acceleration_structure_features &&
5670 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5671 skip |= LogError(
5672 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5673 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5674 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5675 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005676 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5677 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005678 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5679 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005680 }
sourav parmar83c31b12020-05-06 12:30:54 -07005681 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005682 return skip;
5683}
5684
Jason Macnak5c954952019-07-09 15:46:12 -07005685bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5686 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005687 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005688 bool skip = false;
5689 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005690 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5691 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005692 }
5693 return skip;
5694}
5695
sourav parmarcd5fb182020-07-17 12:58:44 -07005696bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5697 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5698 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5699 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005700 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005701 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005702 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005703 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005704 }
5705 return skip;
5706}
5707
Peter Chen85366392019-05-14 15:20:11 -04005708bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5709 uint32_t createInfoCount,
5710 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5711 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005712 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005713 bool skip = false;
5714
5715 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005716 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5717 std::stringstream msg;
5718 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5719 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5720 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005721 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005722 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005723 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005724 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5725 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5726 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5727 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005728 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005729
5730 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005731 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005732 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5733 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5734 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5735 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5736 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5737 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5738 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5739 }
5740 }
5741
sourav parmarf4a78252020-04-10 13:04:21 -07005742 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5743 skip |=
5744 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5745 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5746 }
5747 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5748 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5749 skip |=
5750 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5751 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5752 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5753 }
5754 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5755 if (pCreateInfos[i].basePipelineIndex != -1) {
5756 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5757 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5758 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5759 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5760 "and pCreateInfos->basePipelineIndex is not -1.");
5761 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005762 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005763 skip |=
5764 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5765 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5766 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5767 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5768 "that element.");
5769 }
sourav parmarf4a78252020-04-10 13:04:21 -07005770 }
5771 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005772 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005773 skip |=
5774 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5775 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5776 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5777 "commands pCreateInfos parameter.");
5778 }
5779 } else {
5780 if (pCreateInfos[i].basePipelineIndex != -1) {
5781 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5782 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5783 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5784 }
5785 }
5786 }
5787 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5788 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5789 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5790 }
5791 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5792 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5793 "vkCreateRayTracingPipelinesNV: flags must not include "
5794 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5795 }
5796 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5797 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5798 "vkCreateRayTracingPipelinesNV: flags must not include "
5799 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5800 }
5801 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5802 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5803 "vkCreateRayTracingPipelinesNV: flags must not include "
5804 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5805 }
5806 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5807 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5808 "vkCreateRayTracingPipelinesNV: flags must not include "
5809 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5810 }
5811 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5812 skip |= LogError(
5813 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5814 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5815 }
5816 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5817 skip |= LogError(
5818 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5819 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5820 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005821 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5822 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5823 "vkCreateRayTracingPipelinesNV: flags must not include "
5824 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5825 }
5826 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5827 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5828 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5829 }
ziga-lunargdfffee42021-10-10 11:49:59 +02005830 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
5831 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
5832 "vkCreateRayTracingPipelinesNV: flags must not contain the "
5833 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
5834 }
Peter Chen85366392019-05-14 15:20:11 -04005835 }
5836
5837 return skip;
5838}
5839
sourav parmarcd5fb182020-07-17 12:58:44 -07005840bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5841 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5842 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005843 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005844 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005845 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5846 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5847 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005848 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005849 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005850 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5851 std::stringstream msg;
5852 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5853 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5854 &pCreateInfos[i].pStages[i]);
5855 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005856 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5857 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5858 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5859 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5860 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5861 }
5862 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5863 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5864 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5865 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5866 }
5867 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005868 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005869 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5870 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005871 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5872 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5873 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005874 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5875 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5876 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005877 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005878 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005879 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5880 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5881 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5882 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005883 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005884 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5885 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5886 }
5887 }
sourav parmarf4a78252020-04-10 13:04:21 -07005888 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005889 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5890 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005891 }
5892 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005893 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005894 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005895 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5896 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005897 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005898 }
5899 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5900 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5901 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005902 }
5903 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5904 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5905 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5906 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5907 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5908 skip |= LogError(
5909 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005910 "vkCreateRayTracingPipelinesKHR: If flags includes "
5911 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005912 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5913 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5914 "must not be VK_SHADER_UNUSED_KHR");
5915 }
5916 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5917 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5918 skip |= LogError(
5919 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005920 "vkCreateRayTracingPipelinesKHR: If flags includes "
5921 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005922 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5923 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5924 "element must not be VK_SHADER_UNUSED_KHR");
5925 }
5926 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005927 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5928 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5929 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5930 skip |= LogError(
5931 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5932 "vkCreateRayTracingPipelinesKHR: If "
5933 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5934 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5935 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5936 }
5937 }
sourav parmarf4a78252020-04-10 13:04:21 -07005938 }
5939 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5940 if (pCreateInfos[i].basePipelineIndex != -1) {
5941 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5942 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005943 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005944 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5945 "and pCreateInfos->basePipelineIndex is not -1.");
5946 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005947 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005948 skip |=
5949 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5950 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5951 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5952 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5953 "element.");
5954 }
sourav parmarf4a78252020-04-10 13:04:21 -07005955 }
5956 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005957 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005958 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005959 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005960 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
5961 ") must be a valid into the calling"
5962 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07005963 pCreateInfos[i].basePipelineIndex, createInfoCount);
5964 }
5965 } else {
5966 if (pCreateInfos[i].basePipelineIndex != -1) {
5967 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005968 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005969 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5970 }
5971 }
5972 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005973 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5974 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5975 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5976 "vkCreateRayTracingPipelinesKHR: If flags includes "
5977 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5978 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005979 }
5980 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5981 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5982 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5983 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5984 "pLibraryInfo and pLibraryInterface must be NULL.");
5985 }
5986 if (pCreateInfos[i].pLibraryInfo) {
5987 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5988 if (pCreateInfos[i].stageCount == 0) {
5989 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5990 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5991 "stageCount must not be 0.");
5992 }
5993 if (pCreateInfos[i].groupCount == 0) {
5994 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5995 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5996 "groupCount must not be 0.");
5997 }
5998 } else {
5999 if (pCreateInfos[i].pLibraryInterface == NULL) {
6000 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6001 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6002 "is greater than 0, its "
6003 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006004 }
6005 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006006 }
6007 if (pCreateInfos[i].pLibraryInterface) {
6008 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6009 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6010 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6011 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6012 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6013 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006014 }
6015 if (deferredOperation != VK_NULL_HANDLE) {
6016 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6017 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6018 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6019 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006020 }
6021 }
ziga-lunargdea76582021-09-17 14:38:08 +02006022 if (pCreateInfos[i].pDynamicState) {
6023 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6024 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6025 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6026 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6027 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6028 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6029 }
6030 }
6031 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006032 }
6033
6034 return skip;
6035}
6036
Mike Schuchardt21638df2019-03-16 10:52:02 -07006037#ifdef VK_USE_PLATFORM_WIN32_KHR
6038bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6039 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006040 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006041 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006042 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006043 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006044 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006045 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006046 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006047 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006048 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006049 skip |=
6050 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006051 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006052 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6053 skip |= validate_struct_type(
6054 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6055 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6056 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6057 if (pSurfaceInfo != NULL) {
6058 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6059 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6060 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6061
6062 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6063 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6064 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6065 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006066 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6067 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006068
6069 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6070 }
6071 return skip;
6072}
6073#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006074
6075bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6076 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006077 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006078 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6079 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006080 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006081 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6082 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6083 }
6084 return skip;
6085}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006086
6087bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006088 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006089 bool skip = false;
6090
6091 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006092 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006093 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006094 }
6095
6096 return skip;
6097}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006098
6099bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006100 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006101 bool skip = false;
6102
6103 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006104 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6105 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006106 }
6107
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006108 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006109 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006110 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6111 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006112 }
6113
6114 return skip;
6115}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006116
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006117bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6118 uint32_t bindingCount, const VkBuffer *pBuffers,
6119 const VkDeviceSize *pOffsets) const {
6120 bool skip = false;
6121 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006122 skip |=
6123 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6124 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6125 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006126 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6127 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006128 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6129 ") must be less than "
6130 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006131 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6132 }
6133
Jeff Bolz165818a2020-05-08 11:19:03 -05006134 for (uint32_t i = 0; i < bindingCount; ++i) {
6135 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006136 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006137 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006138 skip |=
6139 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6140 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006141 } else {
6142 if (pOffsets[i] != 0) {
6143 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006144 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6145 "] is not 0",
6146 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006147 }
6148 }
6149 }
6150 }
6151
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006152 return skip;
6153}
6154
Mark Lobodzinski84988402019-09-11 15:27:30 -06006155bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006156 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006157 bool skip = false;
6158 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006159 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6160 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006161 }
6162 return skip;
6163}
6164
6165bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006166 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006167 bool skip = false;
6168 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006169 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6170 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006171 }
6172 return skip;
6173}
Petr Kraus3d720392019-11-13 02:52:39 +01006174
6175bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6176 VkSemaphore semaphore, VkFence fence,
6177 uint32_t *pImageIndex) const {
6178 bool skip = false;
6179
6180 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006181 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6182 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006183 }
6184
6185 return skip;
6186}
6187
6188bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6189 uint32_t *pImageIndex) const {
6190 bool skip = false;
6191
6192 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006193 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6194 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006195 }
6196
6197 return skip;
6198}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006199
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006200bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6201 uint32_t firstBinding, uint32_t bindingCount,
6202 const VkBuffer *pBuffers,
6203 const VkDeviceSize *pOffsets,
6204 const VkDeviceSize *pSizes) const {
6205 bool skip = false;
6206
6207 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6208 for (uint32_t i = 0; i < bindingCount; ++i) {
6209 if (pOffsets[i] & 3) {
6210 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6211 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6212 }
6213 }
6214
6215 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6216 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6217 "%s: The firstBinding(%" PRIu32
6218 ") index is greater than or equal to "
6219 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6220 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6221 }
6222
6223 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6224 skip |=
6225 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6226 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6227 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6228 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6229 }
6230
6231 for (uint32_t i = 0; i < bindingCount; ++i) {
6232 // pSizes is optional and may be nullptr.
6233 if (pSizes != nullptr) {
6234 if (pSizes[i] != VK_WHOLE_SIZE &&
6235 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6236 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6237 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6238 ") is not VK_WHOLE_SIZE and is greater than "
6239 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6240 cmd_name, i, pSizes[i]);
6241 }
6242 }
6243 }
6244
6245 return skip;
6246}
6247
6248bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6249 uint32_t firstCounterBuffer,
6250 uint32_t counterBufferCount,
6251 const VkBuffer *pCounterBuffers,
6252 const VkDeviceSize *pCounterBufferOffsets) const {
6253 bool skip = false;
6254
6255 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6256 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6257 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6258 "%s: The firstCounterBuffer(%" PRIu32
6259 ") index is greater than or equal to "
6260 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6261 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6262 }
6263
6264 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6265 skip |=
6266 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6267 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6268 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6269 cmd_name, firstCounterBuffer, counterBufferCount,
6270 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6271 }
6272
6273 return skip;
6274}
6275
6276bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6277 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6278 const VkBuffer *pCounterBuffers,
6279 const VkDeviceSize *pCounterBufferOffsets) const {
6280 bool skip = false;
6281
6282 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6283 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6284 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6285 "%s: The firstCounterBuffer(%" PRIu32
6286 ") index is greater than or equal to "
6287 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6288 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6289 }
6290
6291 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6292 skip |=
6293 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6294 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6295 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6296 cmd_name, firstCounterBuffer, counterBufferCount,
6297 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6298 }
6299
6300 return skip;
6301}
6302
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006303bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6304 uint32_t firstInstance, VkBuffer counterBuffer,
6305 VkDeviceSize counterBufferOffset,
6306 uint32_t counterOffset, uint32_t vertexStride) const {
6307 bool skip = false;
6308
6309 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006310 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6311 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6312 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6313 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006314 }
6315
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006316 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006317 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006318 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006319 }
6320
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006321 return skip;
6322}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006323
6324bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6325 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6326 const VkAllocationCallbacks *pAllocator,
6327 VkSamplerYcbcrConversion *pYcbcrConversion,
6328 const char *apiName) const {
6329 bool skip = false;
6330
6331 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006332 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006333 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006334 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006335 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6336 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006337 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006338 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006339 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006340
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006341#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006342 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006343 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006344#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006345 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006346#endif
6347
sfricke-samsung1a72f942020-07-25 12:09:18 -07006348 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006349
6350 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006351 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006352 const VkComponentMapping components = pCreateInfo->components;
6353 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6354 if (FormatIsXChromaSubsampled(format) == true) {
6355 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6356 skip |=
6357 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006358 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6359 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006360 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006361 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006362
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006363 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6364 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6365 skip |= LogError(
6366 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6367 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6368 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6369 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6370 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006371
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006372 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6373 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6374 skip |=
6375 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006376 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6377 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006378 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006379 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006380
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006381 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6382 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6383 skip |=
6384 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006385 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6386 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006387 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006388 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006389
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006390 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006391 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6392 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6393 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006394 skip |=
6395 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006396 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6397 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006398 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6399 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006400 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006401 }
6402
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006403 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6404 // Checks same VU multiple ways in order to give a more useful error message
6405 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6406 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6407 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6408 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6409 skip |= LogError(
6410 device, vuid,
6411 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6412 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6413 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6414 string_VkComponentSwizzle(components.b));
6415 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006416
sfricke-samsunged028b02021-09-06 23:14:51 -07006417 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6418 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006419 // 3 = no [a]
6420 // 2 = no [b,a]
6421 // 1 = no [g,b,a]
6422 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006423 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006424
sfricke-samsunged028b02021-09-06 23:14:51 -07006425 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6426 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006427 skip |= LogError(device, vuid,
6428 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6429 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6430 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6431 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006432 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006433 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6434 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6435 skip |= LogError(device, vuid,
6436 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6437 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6438 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6439 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6440 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006441 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006442 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6443 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6444 skip |= LogError(device, vuid,
6445 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6446 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6447 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6448 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6449 string_VkComponentSwizzle(components.b));
6450 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006451 }
6452 }
6453
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006454 return skip;
6455}
6456
6457bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6458 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6459 const VkAllocationCallbacks *pAllocator,
6460 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6461 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6462 "vkCreateSamplerYcbcrConversion");
6463}
6464
6465bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6466 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6467 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6468 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6469 "vkCreateSamplerYcbcrConversionKHR");
6470}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006471
6472bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6473 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6474 bool skip = false;
6475 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6476 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6477
6478 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006479 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6480 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6481 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6482 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6483 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006484 }
6485 return skip;
6486}
sourav parmara96ab1a2020-04-25 16:28:23 -07006487
6488bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006489 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006490 bool skip = false;
6491 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6492 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6493 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6494 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006495 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006496 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6497 skip |= LogError(
6498 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6499 "vkCopyAccelerationStructureToMemoryKHR: The "
6500 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6501 }
6502 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6503 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6504 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6505 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6506 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6507 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006508 return skip;
6509}
6510
6511bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6512 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6513 bool skip = false;
6514 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6515 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6516 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6517 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6518 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006519 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6520 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006521 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006522 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006523 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006524 return skip;
6525}
6526
6527bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6528 const char *api_name) const {
6529 bool skip = false;
6530 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6531 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6532 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6533 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6534 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6535 api_name);
6536 }
6537 return skip;
6538}
6539
6540bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006541 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006542 bool skip = false;
6543 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006544 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006545 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006546 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006547 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6548 "vkCopyAccelerationStructureKHR: The "
6549 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006550 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006551 return skip;
6552}
6553
6554bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6555 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6556 bool skip = false;
6557 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6558 return skip;
6559}
6560
6561bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006562 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006563 bool skip = false;
6564 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006565 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006566 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6567 }
6568 return skip;
6569}
6570
6571bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006572 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006573 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006574 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006575 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006576 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6577 skip |= LogError(
6578 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6579 "vkCopyMemoryToAccelerationStructureKHR: The "
6580 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006581 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006582 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6583 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006584 return skip;
6585}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006586
sourav parmara96ab1a2020-04-25 16:28:23 -07006587bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6588 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6589 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006590 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006591 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6592 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006593 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006594 pInfo->src.deviceAddress);
6595 }
sourav parmar83c31b12020-05-06 12:30:54 -07006596 return skip;
6597}
6598bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6599 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6600 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6601 bool skip = false;
6602 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6603 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6604 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6605 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6606 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6607 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6608 }
6609 return skip;
6610}
6611bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6612 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6613 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6614 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006615 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006616 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6617 skip |= LogError(
6618 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6619 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6620 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6621 }
sourav parmar83c31b12020-05-06 12:30:54 -07006622 if (dataSize < accelerationStructureCount * stride) {
6623 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6624 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006625 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006626 dataSize, accelerationStructureCount, stride);
6627 }
6628 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6629 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6630 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6631 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6632 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6633 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6634 }
6635 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6636 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6637 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6638 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6639 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6640 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6641 stride);
6642 }
6643 }
6644 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6645 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6646 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6647 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6648 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6649 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6650 stride);
6651 }
6652 }
sourav parmar83c31b12020-05-06 12:30:54 -07006653 return skip;
6654}
6655bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6656 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6657 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006658 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006659 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6660 skip |= LogError(
6661 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6662 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6663 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006664 }
6665 return skip;
6666}
6667
6668bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006669 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6670 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6671 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6672 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006673 uint32_t width, uint32_t height, uint32_t depth) const {
6674 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006675 // RayGen
6676 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6677 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6678 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006679 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006680 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6681 0) {
6682 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6683 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6684 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6685 }
6686 // Callable
6687 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6688 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6689 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6690 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006691 }
6692 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6693 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6694 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006695 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6696 }
6697 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6698 0) {
6699 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6700 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6701 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006702 }
6703 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006704 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6705 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6706 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6707 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006708 }
6709 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6710 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006711 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6712 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006713 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006714 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6715 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6716 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6717 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6718 }
sourav parmar83c31b12020-05-06 12:30:54 -07006719 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006720 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6721 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6722 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6723 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006724 }
6725 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6726 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6727 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006728 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6729 }
6730 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6731 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6732 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6733 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6734 }
6735 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6736 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6737 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6738 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6739 }
6740 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6741 skip |=
6742 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6743 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6744 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006745 }
6746
sourav parmarcd5fb182020-07-17 12:58:44 -07006747 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6748 skip |=
6749 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6750 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6751 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6752 }
6753
6754 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6755 skip |=
6756 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6757 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6758 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006759 }
6760 return skip;
6761}
6762
sourav parmarcd5fb182020-07-17 12:58:44 -07006763bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6764 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6765 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6766 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006767 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006768 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006769 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6770 skip |= LogError(
6771 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6772 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6773 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006774 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006775 // RayGen
6776 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6777 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6778 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006779 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006780 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6781 0) {
6782 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6783 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6784 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6785 }
6786 // Callabe
6787 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6788 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6789 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6790 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006791 }
6792 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6793 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006794 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6795 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6796 }
6797 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6798 0) {
6799 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6800 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6801 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006802 }
6803 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006804 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6805 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6806 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6807 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006808 }
6809 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6810 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006811 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6812 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006813 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006814 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6815 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6816 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6817 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6818 }
sourav parmar83c31b12020-05-06 12:30:54 -07006819 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006820 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6821 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6822 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6823 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006824 }
6825 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6826 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006827 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6828 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6829 }
6830 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6831 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6832 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6833 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006834 }
6835
sourav parmarcd5fb182020-07-17 12:58:44 -07006836 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6837 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6838 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006839 }
6840 return skip;
6841}
6842bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6843 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6844 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6845 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6846 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6847 uint32_t width, uint32_t height, uint32_t depth) const {
6848 bool skip = false;
6849 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6850 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6851 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6852 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6853 }
6854 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6855 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6856 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6857 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6858 }
6859 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6860 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6861 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6862 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6863 }
6864
6865 // hitShader
6866 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6867 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6868 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6869 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6870 }
6871 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6872 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6873 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6874 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6875 }
6876 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6877 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6878 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6879 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6880 }
6881
6882 // missShader
6883 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6884 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6885 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6886 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6887 }
6888 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6889 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6890 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6891 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6892 }
6893 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6894 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6895 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6896 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6897 }
6898
6899 // raygenShader
6900 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6901 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6902 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006903 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6904 }
6905 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6906 skip |=
6907 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6908 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6909 }
6910 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6911 skip |=
6912 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6913 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6914 }
6915 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6916 skip |=
6917 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6918 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006919 }
6920 return skip;
6921}
6922
sourav parmar83c31b12020-05-06 12:30:54 -07006923bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006924 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6925 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006926 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006927 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6928 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006929 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6930 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006931 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006932 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6933 }
6934 return skip;
6935}
6936
Piers Daniell39842ee2020-07-10 16:42:33 -06006937bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6938 const VkViewport *pViewports) const {
6939 bool skip = false;
6940
6941 if (!physical_device_features.multiViewport) {
6942 if (viewportCount != 1) {
6943 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6944 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6945 ") is not 1.",
6946 viewportCount);
6947 }
6948 } else { // multiViewport enabled
6949 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6950 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6951 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6952 ") must "
6953 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6954 viewportCount, device_limits.maxViewports);
6955 }
6956 }
6957
6958 if (pViewports) {
6959 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6960 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6961 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6962 skip |= manual_PreCallValidateViewport(
6963 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6964 }
6965 }
6966
6967 return skip;
6968}
6969
6970bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6971 const VkRect2D *pScissors) const {
6972 bool skip = false;
6973
6974 if (!physical_device_features.multiViewport) {
6975 if (scissorCount != 1) {
6976 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6977 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6978 ") must "
6979 "be 1 when the multiViewport feature is disabled.",
6980 scissorCount);
6981 }
6982 } else { // multiViewport enabled
6983 if (scissorCount == 0) {
6984 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6985 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6986 ") must "
6987 "be great than zero.",
6988 scissorCount);
6989 } else if (scissorCount > device_limits.maxViewports) {
6990 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6991 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6992 ") must "
6993 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6994 scissorCount, device_limits.maxViewports);
6995 }
6996 }
6997
6998 if (pScissors) {
6999 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7000 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7001
7002 if (scissor.offset.x < 0) {
7003 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7004 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
7005 scissor.offset.x);
7006 }
7007
7008 if (scissor.offset.y < 0) {
7009 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7010 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
7011 scissor.offset.y);
7012 }
7013
7014 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7015 if (x_sum > INT32_MAX) {
7016 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
7017 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7018 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7019 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
7020 }
7021
7022 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7023 if (y_sum > INT32_MAX) {
7024 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
7025 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7026 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7027 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7028 }
7029 }
7030 }
7031
7032 return skip;
7033}
7034
7035bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7036 uint32_t bindingCount, const VkBuffer *pBuffers,
7037 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7038 const VkDeviceSize *pStrides) const {
7039 bool skip = false;
7040 if (firstBinding >= device_limits.maxVertexInputBindings) {
7041 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007042 "vkCmdBindVertexBuffers2EXT() firstBinding (%" PRIu32
7043 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007044 firstBinding, device_limits.maxVertexInputBindings);
7045 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7046 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007047 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7048 ") must be less than "
7049 "maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007050 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7051 }
7052
7053 for (uint32_t i = 0; i < bindingCount; ++i) {
7054 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007055 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06007056 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007057 skip |= LogError(
7058 commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
7059 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007060 } else {
7061 if (pOffsets[i] != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007062 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
7063 "vkCmdBindVertexBuffers2EXT() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
7064 "] is not 0",
7065 i, i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007066 }
7067 }
7068 }
7069 if (pStrides) {
7070 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007071 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
7072 "vkCmdBindVertexBuffers2EXT() pStrides[%" PRIu32 "] (%" PRIu64
7073 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7074 i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007075 }
7076 }
7077 }
7078
7079 return skip;
7080}
sourav parmarcd5fb182020-07-17 12:58:44 -07007081
7082bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7083 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7084 bool skip = false;
7085 for (uint32_t i = 0; i < infoCount; ++i) {
7086 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7087 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7088 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7089 }
7090 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7091 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7092 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7093 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7094 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7095 api_name);
7096 }
7097 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7098 skip |=
7099 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7100 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7101 }
7102 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7103 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7104 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7105 }
7106 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7107 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7108 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7109 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7110 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7111 api_name);
7112 }
7113 if (pInfos[i].pGeometries) {
7114 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7115 skip |= validate_ranged_enum(
7116 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7117 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7118 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7119 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007120 skip |= validate_struct_type(
7121 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7122 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7123 &(pInfos[i].pGeometries[j].geometry.triangles),
7124 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7125 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7126 skip |= validate_struct_pnext(
7127 api_name,
7128 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7129 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7130 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7131 skip |=
7132 validate_ranged_enum(api_name,
7133 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7134 ParameterName::IndexVector{i, j}),
7135 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7136 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7137 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7138 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7139 &pInfos[i].pGeometries[j].geometry.triangles,
7140 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7141 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7142 skip |= validate_ranged_enum(
7143 api_name,
7144 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7145 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7146 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7147
7148 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7149 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7150 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7151 }
7152 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7153 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7154 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7155 skip |=
7156 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7157 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7158 api_name);
7159 }
7160 }
7161 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7162 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7163 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7164 &pInfos[i].pGeometries[j].geometry.instances,
7165 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7166 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7167 skip |= validate_struct_type(
7168 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7169 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7170 &(pInfos[i].pGeometries[j].geometry.instances),
7171 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7172 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7173 skip |= validate_struct_pnext(
7174 api_name,
7175 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7176 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7177 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7178
7179 skip |= validate_bool32(api_name,
7180 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7181 ParameterName::IndexVector{i, j}),
7182 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7183 }
7184 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7185 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7186 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7187 &pInfos[i].pGeometries[j].geometry.aabbs,
7188 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7189 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7190 skip |= validate_struct_type(
7191 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7192 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7193 &(pInfos[i].pGeometries[j].geometry.aabbs),
7194 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7195 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7196 skip |= validate_struct_pnext(
7197 api_name,
7198 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7199 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7200 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7201 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7202 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7203 "(%s):stride must be less than or equal to 2^32-1", api_name);
7204 }
7205 }
7206 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7207 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7208 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7209 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7210 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7211 api_name);
7212 }
7213 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7214 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7215 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7216 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7217 "of elements of"
7218 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7219 api_name);
7220 }
7221 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7222 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7223 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7224 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7225 api_name);
7226 }
7227 }
7228 }
7229 }
7230 if (pInfos[i].ppGeometries != NULL) {
7231 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7232 skip |= validate_ranged_enum(
7233 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7234 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7235 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7236 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007237 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7238 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7239 &pInfos[i].ppGeometries[j]->geometry.triangles,
7240 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7241 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7242 skip |= validate_struct_type(
7243 api_name,
7244 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7245 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7246 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7247 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7248 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7249 skip |= validate_struct_pnext(
7250 api_name,
7251 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7252 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7253 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7254 skip |= validate_ranged_enum(api_name,
7255 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7256 ParameterName::IndexVector{i, j}),
7257 "VkFormat", AllVkFormatEnums,
7258 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7259 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7260 skip |= validate_ranged_enum(api_name,
7261 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7262 ParameterName::IndexVector{i, j}),
7263 "VkIndexType", AllVkIndexTypeEnums,
7264 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7265 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7266 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7267 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7268 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7269 }
7270 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7271 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7272 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7273 skip |=
7274 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7275 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7276 api_name);
7277 }
7278 }
7279 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7280 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7281 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7282 &pInfos[i].ppGeometries[j]->geometry.instances,
7283 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7284 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7285 skip |= validate_struct_type(
7286 api_name,
7287 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7288 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7289 &(pInfos[i].ppGeometries[j]->geometry.instances),
7290 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7291 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7292 skip |= validate_struct_pnext(
7293 api_name,
7294 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7295 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7296 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7297 skip |= validate_bool32(api_name,
7298 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7299 ParameterName::IndexVector{i, j}),
7300 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7301 }
7302 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7303 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7304 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7305 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7306 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7307 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7308 skip |= validate_struct_type(
7309 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7310 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7311 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7312 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7313 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7314 skip |= validate_struct_pnext(
7315 api_name,
7316 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7317 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7318 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7319 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7320 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7321 "(%s):stride must be less than or equal to 2^32-1", api_name);
7322 }
7323 }
7324 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7325 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7326 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7327 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7328 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7329 api_name);
7330 }
7331 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7332 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7333 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7334 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7335 "of elements of"
7336 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7337 api_name);
7338 }
7339 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7340 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7341 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7342 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7343 api_name);
7344 }
7345 }
7346 }
7347 }
7348 }
7349 return skip;
7350}
7351bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7352 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7353 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7354 bool skip = false;
7355 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7356 for (uint32_t i = 0; i < infoCount; ++i) {
7357 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7358 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7359 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7360 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7361 "scratchData.deviceAddress member must be a multiple of "
7362 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7363 }
7364 for (uint32_t k = 0; k < infoCount; ++k) {
7365 if (i == k) continue;
7366 bool found = false;
7367 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007368 skip |=
7369 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7370 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7371 ") of pInfos must "
7372 "not be "
7373 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7374 ") of pInfos.",
7375 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007376 found = true;
7377 }
7378 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007379 skip |=
7380 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7381 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7382 ") of pInfos must "
7383 "not be "
7384 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7385 ") of pInfos.",
7386 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007387 found = true;
7388 }
7389 if (found) break;
7390 }
7391 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7392 if (pInfos[i].pGeometries) {
7393 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7394 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7395 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7396 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7397 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7398 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7399 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7400 }
7401 } else {
7402 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7403 skip |=
7404 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7405 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7406 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7407 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7408 }
7409 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007410 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007411 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7412 skip |= LogError(
7413 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7414 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7415 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7416 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007417 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7418 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007419 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7420 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7421 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7422 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7423 }
7424 }
7425 } else if (pInfos[i].ppGeometries) {
7426 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7427 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7428 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7429 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7430 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7431 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7432 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7433 }
7434 } else {
7435 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7436 skip |=
7437 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7438 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7439 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7440 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7441 }
7442 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007443 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007444 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7445 skip |= LogError(
7446 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7447 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7448 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7449 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007450 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7451 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007452 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7453 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7454 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7455 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7456 }
7457 }
7458 }
7459 }
7460 }
7461 return skip;
7462}
7463
7464bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7465 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7466 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7467 const uint32_t *const *ppMaxPrimitiveCounts) const {
7468 bool skip = false;
7469 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7470 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007471 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007472 if (!ray_tracing_acceleration_structure_features ||
7473 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7474 skip |= LogError(
7475 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7476 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7477 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7478 }
7479 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007480 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7481 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7482 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7483 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7484 "scratchData.deviceAddress member must be a multiple of "
7485 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7486 }
7487 for (uint32_t k = 0; k < infoCount; ++k) {
7488 if (i == k) continue;
7489 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007490 skip |= LogError(
7491 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7492 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7493 ") "
7494 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7495 "any other element [%" PRIu32 ") of pInfos.",
7496 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007497 break;
7498 }
7499 }
7500 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7501 if (pInfos[i].pGeometries) {
7502 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7503 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7504 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7505 skip |= LogError(
7506 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7507 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7508 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7509 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7510 }
7511 } else {
7512 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7513 skip |= LogError(
7514 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7515 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7516 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7517 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7518 }
7519 }
7520 }
7521 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7522 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7523 skip |= LogError(
7524 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7525 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7526 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7527 }
7528 }
7529 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7530 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7531 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7532 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7533 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7534 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7535 }
7536 }
7537 } else if (pInfos[i].ppGeometries) {
7538 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7539 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7540 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7541 skip |= LogError(
7542 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7543 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7544 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7545 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7546 }
7547 } else {
7548 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7549 skip |= LogError(
7550 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7551 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7552 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7553 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7554 }
7555 }
7556 }
7557 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7558 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7559 skip |= LogError(
7560 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7561 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7562 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7563 }
7564 }
7565 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7566 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7567 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7568 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7569 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7570 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7571 }
7572 }
7573 }
7574 }
7575 }
7576 return skip;
7577}
7578
7579bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7580 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7581 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7582 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7583 bool skip = false;
7584 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7585 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007586 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007587 if (!ray_tracing_acceleration_structure_features ||
7588 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7589 skip |=
7590 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7591 "vkBuildAccelerationStructuresKHR: The "
7592 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7593 }
7594 for (uint32_t i = 0; i < infoCount; ++i) {
7595 for (uint32_t j = 0; j < infoCount; ++j) {
7596 if (i == j) continue;
7597 bool found = false;
7598 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007599 skip |=
7600 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7601 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
7602 ") of pInfos must "
7603 "not be "
7604 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7605 ") of pInfos.",
7606 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007607 found = true;
7608 }
7609 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007610 skip |=
7611 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7612 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
7613 ") of pInfos must "
7614 "not be "
7615 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7616 ") of pInfos.",
7617 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007618 found = true;
7619 }
7620 if (found) break;
7621 }
7622 }
7623 return skip;
7624}
7625
7626bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7627 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7628 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7629 bool skip = false;
7630 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7631 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007632 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7633 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007634 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7635 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7636 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7637 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7638 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7639 }
7640 return skip;
7641}
sfricke-samsungecafb192021-01-17 08:21:14 -08007642
7643bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7644 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7645 const VkAllocationCallbacks *pAllocator,
7646 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7647 bool skip = false;
7648 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7649 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7650 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7651 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7652 }
7653 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007654}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007655
7656bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7657 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7658 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7659 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7660 bool skip = false;
7661 const auto *vertex_input_dynamic_state_features =
7662 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7663 const auto *vertex_attribute_divisor_features =
7664 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7665
7666 // VUID-vkCmdSetVertexInputEXT-None-04790
7667 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7668 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7669 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7670 }
7671
7672 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7673 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7674 skip |=
7675 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7676 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7677 }
7678
7679 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7680 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7681 skip |= LogError(
7682 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7683 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7684 }
7685
7686 // VUID-vkCmdSetVertexInputEXT-binding-04793
7687 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7688 bool binding_found = false;
7689 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7690 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7691 binding_found = true;
7692 break;
7693 }
7694 }
7695 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007696 skip |= LogError(
7697 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7698 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007699 }
7700 }
7701
7702 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7703 if (vertexBindingDescriptionCount > 1) {
7704 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7705 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7706 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7707 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7708 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007709 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
7710 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007711 }
7712 }
7713 }
7714 }
7715
7716 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7717 if (vertexAttributeDescriptionCount > 1) {
7718 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7719 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7720 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7721 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7722 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007723 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
7724 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007725 }
7726 }
7727 }
7728 }
7729
7730 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7731 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7732 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007733 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7734 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7735 "].binding is greater than maxVertexInputBindings",
7736 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007737 }
7738
7739 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7740 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007741 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7742 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7743 "].stride is greater than maxVertexInputBindingStride",
7744 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007745 }
7746
7747 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7748 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7749 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7750 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007751 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7752 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007753 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7754 binding);
7755 }
7756
7757 if (pVertexBindingDescriptions[binding].divisor > 1) {
7758 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7759 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7760 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007761 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7762 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007763 "vertexAttributeInstanceRateDivisor is not enabled",
7764 binding);
7765 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007766 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007767 if (pVertexBindingDescriptions[binding].divisor >
7768 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007769 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
7770 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7771 "].divisor is greater than maxVertexAttribDivisor",
7772 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007773 }
7774
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007775 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007776 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007777 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
7778 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7779 "].divisor is greater than 1 but inputRate "
7780 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7781 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007782 }
7783 }
7784 }
7785 }
7786
7787 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007788 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007789 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007790 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
7791 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7792 "].location is greater than maxVertexInputAttributes",
7793 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007794 }
7795
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007796 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007797 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007798 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
7799 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7800 "].binding is greater than maxVertexInputBindings",
7801 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007802 }
7803
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007804 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007805 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007806 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
7807 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7808 "].offset is greater than maxVertexInputAttributeOffset",
7809 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007810 }
7811
7812 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7813 VkFormatProperties properties;
7814 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7815 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7816 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007817 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7818 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007819 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7820 attribute);
7821 }
7822 }
7823
7824 return skip;
7825}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007826
7827bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7828 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7829 const void *pValues) const {
7830 bool skip = false;
7831 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7832 // Check that offset + size don't exceed the max.
7833 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7834 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007835 skip |=
7836 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7837 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
7838 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007839 }
7840 if (size > max_push_constants_size - offset) {
7841 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007842 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
7843 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07007844 offset, size, max_push_constants_size);
7845 }
7846
7847 // size needs to be non-zero and a multiple of 4.
7848 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007849 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
7850 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007851 }
7852
7853 // offset needs to be a multiple of 4.
7854 if ((offset & 0x3) != 0) {
7855 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007856 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007857 }
7858 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007859}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007860
7861bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7862 uint32_t srcCacheCount,
7863 const VkPipelineCache *pSrcCaches) const {
7864 bool skip = false;
7865 if (pSrcCaches) {
7866 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7867 if (pSrcCaches[index0] == dstCache) {
7868 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7869 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7870 report_data->FormatHandle(dstCache).c_str());
7871 break;
7872 }
7873 }
7874 }
7875 return skip;
7876}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007877
7878bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
7879 VkImageLayout imageLayout, const VkClearColorValue *pColor,
7880 uint32_t rangeCount,
7881 const VkImageSubresourceRange *pRanges) const {
7882 bool skip = false;
7883 if (!pColor) {
7884 skip |=
7885 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
7886 }
7887 return skip;
7888}
7889
7890bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
7891 const VkRenderPassBeginInfo *const rp_begin) const {
7892 bool skip = false;
7893 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
7894 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
7895 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02007896 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007897 func_name, rp_begin->clearValueCount);
7898 }
7899 return skip;
7900}
7901
7902bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7903 VkSubpassContents) const {
7904 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
7905 return skip;
7906}
7907
7908bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
7909 const VkRenderPassBeginInfo *pRenderPassBegin,
7910 const VkSubpassBeginInfo *) const {
7911 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
7912 return skip;
7913}
7914
7915bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7916 const VkSubpassBeginInfo *) const {
7917 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
7918 return skip;
7919}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02007920
7921bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
7922 uint32_t firstDiscardRectangle,
7923 uint32_t discardRectangleCount,
7924 const VkRect2D *pDiscardRectangles) const {
7925 bool skip = false;
7926
7927 if (pDiscardRectangles) {
7928 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
7929 const int64_t x_sum =
7930 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
7931 if (x_sum > std::numeric_limits<int32_t>::max()) {
7932 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
7933 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7934 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7935 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
7936 }
7937
7938 const int64_t y_sum =
7939 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
7940 if (y_sum > std::numeric_limits<int32_t>::max()) {
7941 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
7942 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7943 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7944 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
7945 }
7946 }
7947 }
7948
7949 return skip;
7950}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02007951
7952bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
7953 uint32_t queryCount, size_t dataSize, void *pData,
7954 VkDeviceSize stride, VkQueryResultFlags flags) const {
7955 bool skip = false;
7956
7957 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
7958 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
7959 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
7960 }
7961
7962 return skip;
7963}
ziga-lunargcf340c42021-08-19 00:13:38 +02007964
7965bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
7966 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
7967 bool skip = false;
7968
7969 if ((pConditionalRenderingBegin->offset & 3) != 0) {
7970 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
7971 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
7972 ") is not a multiple of 4.",
7973 pConditionalRenderingBegin->offset);
7974 }
7975
7976 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06007977}