blob: f78a39d7d81ab065ac189a87a8f2377cefc81a0b [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 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700580 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700581 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
582 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
583 "protectedMemory feature being set as well.");
584 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600585 }
586 }
587
sfricke-samsung30a57412020-05-15 21:14:54 -0700588 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700589 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700590 VkBool32 variable_pointers = VK_FALSE;
591 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700592 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700593 variable_pointers = vulkan_11_features->variablePointers;
594 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700595 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700596 variable_pointers = variable_pointers_features->variablePointers;
597 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700598 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700599 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700600 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
601 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
602 }
603
sfricke-samsungfd76c342020-05-29 23:13:43 -0700604 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700605 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700606 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700607 VkBool32 multiview_geometry_shader = VK_FALSE;
608 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700609 if (vulkan_11_features) {
610 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700611 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
612 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700613 } else if (multiview_features) {
614 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700615 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
616 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700617 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700618 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700619 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
620 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
621 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700622 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700623 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
624 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
625 }
626
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600627 return skip;
628}
629
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500630bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700631 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700632 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
633 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
634 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600635 }
636
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700637 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600638}
639
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700640bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500641 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100642 bool skip = false;
643
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600644 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700645 skip |=
646 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600647
648 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
649 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
650 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
651 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700652 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
653 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
654 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600655 }
656
657 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
658 // queueFamilyIndexCount uint32_t values
659 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700660 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
661 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
662 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
663 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600664 }
665 }
666
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700667 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
668 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
669 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
670 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
671 }
672
673 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
674 skip |=
675 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
676 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
677 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
678 }
679
680 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
681 skip |=
682 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
683 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
684 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
685 }
686
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600687 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
688 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
689 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
690 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700691 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
692 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
693 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600694 }
695 }
696
697 return skip;
698}
699
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700700bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500701 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600702 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703
704 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800705 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700706 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600707 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
708 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
709 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
710 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
712 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
713 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714 }
715
716 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
717 // queueFamilyIndexCount uint32_t values
718 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700719 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
720 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
721 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
722 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600723 }
724 }
725
Dave Houlton413a6782018-05-22 13:01:54 -0600726 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700727 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600728 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700729 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600730 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700731 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600732
Dave Houlton413a6782018-05-22 13:01:54 -0600733 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700734 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600735 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700736 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600737
Dave Houlton130c0212018-01-29 13:39:56 -0700738 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700739 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
740 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700741 skip |= LogError(
742 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600743 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
744 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700745 }
746
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600747 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100748 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
749 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
751 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
752 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 }
754
755 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700756 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100757 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700758 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
759 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
760 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
761 ") are not equal.",
762 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100763 }
764
765 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
767 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
768 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
769 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100770 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600771 }
772
773 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700774 skip |= LogError(
775 device, "VUID-VkImageCreateInfo-imageType-00957",
776 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600777 }
778 }
779
Dave Houlton130c0212018-01-29 13:39:56 -0700780 // 3D image may have only 1 layer
781 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700782 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
783 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700784 }
785
Dave Houlton130c0212018-01-29 13:39:56 -0700786 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
787 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
788 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
789 // At least one of the legal attachment bits must be set
790 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700791 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
792 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700793 }
794 // No flags other than the legal attachment bits may be set
795 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
796 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
798 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700799 }
800 }
801
Jeff Bolzef40fec2018-09-01 22:04:34 -0500802 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700803 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500804 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700805 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700806 ? static_cast<uint32_t>(ceil(log2(max_dim)))
807 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
808 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600809 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700810 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
811 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
812 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600813 }
814
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700815 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700816 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
817 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
818 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600819 }
820
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700821 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700822 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
823 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
824 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100825 }
826
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700827 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700828 skip |= LogError(
829 device, "VUID-VkImageCreateInfo-flags-01924",
830 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
831 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
832 }
833
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600834 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
835 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700836 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
837 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700838 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
839 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
840 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600841 }
842
843 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700844 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600845 // Linear tiling is unsupported
846 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700847 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700848 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
849 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600850 }
851
852 // Sparse 1D image isn't valid
853 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700854 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
855 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600856 }
857
858 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700859 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700860 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
861 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
862 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600863 }
864
865 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700866 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700867 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
868 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
869 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600870 }
871
872 // Multi-sample 2D image when device doesn't support it
873 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700874 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600875 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700876 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
877 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
878 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700879 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600880 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700881 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
882 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
883 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700884 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600885 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700886 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
887 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
888 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700889 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600890 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700891 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
892 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
893 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600894 }
895 }
896 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500897
Jeff Bolz9af91c52018-09-01 21:53:57 -0500898 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
899 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700900 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
901 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
902 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500903 }
904 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700905 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
906 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
907 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500908 }
909 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700910 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
911 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
912 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500913 }
914 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500915
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700916 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600917 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700918 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
919 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
920 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500921 }
922
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700923 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700924 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
925 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800926 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
927 "depth/stencil format.",
928 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500929 }
930
Dave Houlton142c4cb2018-10-17 15:04:41 -0600931 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700932 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
933 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
934 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
935 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500936 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600937 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700938 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
939 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
940 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
941 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500942 }
943 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500944
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700945 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800946 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700947 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
948 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800949 "format (%s) must be a depth or depth/stencil format.",
950 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700951 }
952
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700953 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500954 if (image_stencil_struct != nullptr) {
955 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
956 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
957 // No flags other than the legal attachment bits may be set
958 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
959 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700960 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
961 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
962 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
963 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500964 }
965 }
966
sfricke-samsung61a57c02021-01-10 21:35:12 -0800967 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500968 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
969 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -0700970 skip |=
971 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
972 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
973 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32
974 ") exceeds device "
975 "maxFramebufferWidth (%" PRIu32 ")",
976 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500977 }
978
979 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -0700980 skip |=
981 LogError(device, "VUID-VkImageCreateInfo-format-02537",
982 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
983 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32
984 ") exceeds device "
985 "maxFramebufferHeight (%" PRIu32 ")",
986 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500987 }
988 }
989
990 if (!physical_device_features.shaderStorageImageMultisample &&
991 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
992 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
993 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700994 LogError(device, "VUID-VkImageCreateInfo-format-02538",
995 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
996 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
997 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500998 }
999
1000 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
1001 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001002 skip |= LogError(
1003 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001004 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1005 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1006 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1007 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1008 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001009 skip |= LogError(
1010 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001011 "vkCreateImage(): Depth-stencil image in which usage does not include "
1012 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1013 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1014 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1015 }
1016
1017 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1018 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001019 skip |= LogError(
1020 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001021 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1022 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1023 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1024 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1025 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001026 skip |= LogError(
1027 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001028 "vkCreateImage(): Depth-stencil image in which usage does not include "
1029 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1030 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1031 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1032 }
1033 }
1034 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001035
1036 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1037 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1038 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1039 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1040 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1041 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001042
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001043 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001044 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001045 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1046 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001047 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1048 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1049 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1050 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1051 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1052 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1053 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001054 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001055 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1056 } else if (drm_format_mod_list != nullptr) {
1057 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1058 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1059 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001060 }
1061 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1062 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1063 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1064 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1065 "in the pNext chain");
1066 }
1067 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001068
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001069 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001070 bool image_create_maybe_linear = false;
1071 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1072 image_create_maybe_linear = true;
1073 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1074 image_create_maybe_linear = false;
1075 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1076 image_create_maybe_linear =
1077 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001078 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001079 }
1080
1081 // If multi-sample, validate type, usage, tiling and mip levels.
1082 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001083 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001084 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1085 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1086 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1087 }
1088
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001089 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001090 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1091 image_create_maybe_linear)) {
1092 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1093 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1094 }
1095
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001096 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1097 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1098 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1099 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1100 "imageType must be VK_IMAGE_TYPE_2D.");
1101 }
1102 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1103 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1104 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1105 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1106 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001107 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001108 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001109 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1110 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1111 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1112 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1113 }
1114 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1115 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1116 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1117 "imageType must be VK_IMAGE_TYPE_2D.");
1118 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001119 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001120 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1121 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1122 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1123 }
1124 if (pCreateInfo->mipLevels != 1) {
1125 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001126 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32
1127 ") must be 1.",
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001128 pCreateInfo->mipLevels);
1129 }
1130 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001131
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001132 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001133 if (swapchain_create_info != nullptr) {
1134 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1135 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1136 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1137 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1138 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1139 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1140
1141 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1142 // also implicitly forces the check above that extent.depth is 1
1143 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1144 string_VkImageType(pCreateInfo->imageType));
1145 }
1146 if (pCreateInfo->mipLevels != 1) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001147 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %" PRIu32 ".", base_message,
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001148 pCreateInfo->mipLevels);
1149 }
1150 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1151 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1152 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1153 }
1154 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1155 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1156 base_message, string_VkImageTiling(pCreateInfo->tiling));
1157 }
1158 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1159 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1160 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1161 }
1162 const VkImageCreateFlags valid_flags =
1163 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001164 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001165 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001166 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001167 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001168 }
1169 }
1170 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001171
1172 // If Chroma subsampled format ( _420_ or _422_ )
1173 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1174 skip |=
1175 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1176 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1177 ") must be a multiple of 2.",
1178 string_VkFormat(image_format), pCreateInfo->extent.width);
1179 }
1180 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1181 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1182 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1183 ") must be a multiple of 2.",
1184 string_VkFormat(image_format), pCreateInfo->extent.height);
1185 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001186
1187 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1188 if (format_list_info) {
1189 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1190 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1191 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1192 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001193 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.",
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001194 viewFormatCount);
1195 }
1196 // Check if viewFormatCount is not zero that it is all compatible
1197 for (uint32_t i = 0; i < viewFormatCount; i++) {
1198 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1199 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001200 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1201 "] (%s) and "
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001202 "VkImageCreateInfo::format (%s) are not compatible.",
Esther O'Keefed37c24b2021-09-27 12:45:40 +10001203 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001204 }
1205 }
1206 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001207 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001208
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001209 return skip;
1210}
1211
Jeff Bolz99e3f632020-03-24 22:59:22 -05001212bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1213 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1214 bool skip = false;
1215
1216 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001217 // Validate feature set if using CUBE_ARRAY
1218 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1219 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1220 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1221 "enabling the imageCubeArray feature.");
1222 }
1223
Jeff Bolz99e3f632020-03-24 22:59:22 -05001224 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1225 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1226 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001227 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1228 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001229 pCreateInfo->subresourceRange.layerCount);
1230 }
1231 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001232 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1233 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1234 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1235 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001236 }
1237 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001238
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001239 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001240 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001241 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1242 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1243 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1244 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1245 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1246 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1247 }
1248 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1249 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1250 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1251 "not an ASTC format.",
1252 string_VkFormat(pCreateInfo->format));
1253 }
1254 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001255
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001256 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001257 if (ycbcr_conversion != nullptr) {
1258 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1259 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1260 skip |= LogError(
1261 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1262 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1263 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1264 "r swizzle = %s\n"
1265 "g swizzle = %s\n"
1266 "b swizzle = %s\n"
1267 "a swizzle = %s\n",
1268 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1269 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1270 }
1271 }
1272 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001273 }
1274 return skip;
1275}
1276
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001277bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001278 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001279 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001280
1281 // Note: for numerical correctness
1282 // - float comparisons should expect NaN (comparison always false).
1283 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1284
1285 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001286 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001287 if (v1_f <= 0.0f) return true;
1288
1289 float intpart;
1290 const float fract = modff(v1_f, &intpart);
1291
1292 assert(std::numeric_limits<float>::radix == 2);
1293 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1294 if (intpart >= u32_max_plus1) return false;
1295
1296 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001297 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001298 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001299 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001300 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001301 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001302 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001303 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001304 };
1305
1306 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1307 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1308 return (v1_f <= v2_f);
1309 };
1310
1311 // width
1312 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001313 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001314
1315 if (!(viewport.width > 0.0f)) {
1316 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001317 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1318 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001319 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1320 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001321 skip |= LogError(object, "VUID-VkViewport-width-01771",
1322 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1323 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001324 }
1325
1326 // height
1327 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001328 const bool negative_height_enabled =
1329 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001330 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001331
1332 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1333 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001334 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1335 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001336 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1337 height_healthy = false;
1338
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001339 skip |= LogError(object, "VUID-VkViewport-height-01773",
1340 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1341 ").",
1342 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001343 }
1344
1345 // x
1346 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001347 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001348 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001349 skip |= LogError(object, "VUID-VkViewport-x-01774",
1350 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1351 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001352 }
1353
1354 // x + width
1355 if (x_healthy && width_healthy) {
1356 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001357 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001358 skip |= LogError(
1359 object, "VUID-VkViewport-x-01232",
1360 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1361 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1362 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001363 }
1364 }
1365
1366 // y
1367 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001368 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001369 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001370 skip |= LogError(object, "VUID-VkViewport-y-01775",
1371 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1372 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001373 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001374 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001375 skip |= LogError(object, "VUID-VkViewport-y-01776",
1376 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1377 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001378 }
1379
1380 // y + height
1381 if (y_healthy && height_healthy) {
1382 const float boundary = viewport.y + viewport.height;
1383
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001384 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001385 skip |= LogError(object, "VUID-VkViewport-y-01233",
1386 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1387 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1388 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001389 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001390 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001391 LogError(object, "VUID-VkViewport-y-01777",
1392 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1393 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1394 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001395 }
1396 }
1397
sfricke-samsungfd06d422021-01-22 02:17:21 -08001398 // The extension was not created with a feature bit whichs prevents displaying the 2 variations of the VUIDs
sfricke-samsung45996a42021-09-16 13:45:27 -07001399 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001400 // minDepth
1401 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001402 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001403 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001404 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1405 "[0.0, 1.0] range.",
1406 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001407 }
1408
1409 // maxDepth
1410 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001411 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001412 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001413 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1414 "[0.0, 1.0] range.",
1415 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001416 }
1417 }
1418
1419 return skip;
1420}
1421
Dave Houlton142c4cb2018-10-17 15:04:41 -06001422struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001423 VkShadingRatePaletteEntryNV shadingRate;
1424 uint32_t width;
1425 uint32_t height;
1426};
1427
1428// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001429static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001430 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1431 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1432 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1433 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1434 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1435 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001436};
1437
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001438bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001439 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001440
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001441 SampleOrderInfo *sample_order_info;
1442 uint32_t info_idx = 0;
1443 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1444 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1445 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001446 break;
1447 }
1448 }
1449
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001450 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001451 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1452 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1453 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001454 return skip;
1455 }
1456
Dave Houlton142c4cb2018-10-17 15:04:41 -06001457 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001458 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001459 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1460 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1461 ") must "
1462 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1463 "is set in framebufferNoAttachmentsSampleCounts.",
1464 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001465 }
1466
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001467 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001468 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1469 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1470 ") must "
1471 "be equal to the product of sampleCount (=%" PRIu32
1472 "), the fragment width for shadingRate "
1473 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001474 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001475 }
1476
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001477 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001478 skip |= LogError(
1479 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001480 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1481 ") must "
1482 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001483 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001484 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001485
1486 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001487 // the first width*height*sampleCount bits to all be set. Note: There is no
1488 // guarantee that 64 bits is enough, but practically it's unlikely for an
1489 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001490 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001491 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001492 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001493 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1494 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001495 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1496 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001497 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001498 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001499 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1500 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001501 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001502 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001503 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1504 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001505 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001506 uint32_t idx =
1507 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1508 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001509 }
1510
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001511 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1512 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001513 skip |= LogError(
1514 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001515 "The array pSampleLocations must contain exactly one entry for "
1516 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001517 }
1518
1519 return skip;
1520}
1521
sfricke-samsung51303fb2021-05-09 19:09:13 -07001522bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1523 const VkAllocationCallbacks *pAllocator,
1524 VkPipelineLayout *pPipelineLayout) const {
1525 bool skip = false;
1526 // Validate layout count against device physical limit
1527 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1528 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001529 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1530 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001531 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1532 }
1533
1534 // Validate Push Constant ranges
1535 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1536 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1537 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1538 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1539 // Check that offset + size don't exceed the max.
1540 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1541 if (offset >= max_push_constants_size) {
1542 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001543 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1544 ") that exceeds this "
1545 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001546 i, offset, max_push_constants_size);
1547 }
1548 if (size > max_push_constants_size - offset) {
1549 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001550 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1551 ") and size (%" PRIu32
1552 ") "
1553 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001554 i, offset, size, max_push_constants_size);
1555 }
1556
1557 // size needs to be non-zero and a multiple of 4.
1558 if (size == 0) {
1559 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001560 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1561 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001562 i, size);
1563 }
1564 if (size & 0x3) {
1565 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001566 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1567 ") is not a multiple of 4.",
1568 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001569 }
1570
1571 // offset needs to be a multiple of 4.
1572 if ((offset & 0x3) != 0) {
1573 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001574 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1575 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001576 i, offset);
1577 }
1578 }
1579
1580 // As of 1.0.28, there is a VU that states that a stage flag cannot appear more than once in the list of push constant ranges.
1581 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1582 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1583 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001584 skip |=
1585 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1586 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001587 }
1588 }
1589 }
1590 return skip;
1591}
1592
ziga-lunargc6341372021-07-28 12:57:42 +02001593bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1594 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1595 bool skip = false;
1596
1597 const auto *required_subgroup_size_features =
1598 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1599
1600 if (required_subgroup_size_features) {
1601 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1602 skip |= LogError(
1603 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1604 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1605 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1606 func_name, msg, pCreateInfo->flags);
1607 }
1608 }
1609
1610 return skip;
1611}
1612
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001613bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1614 uint32_t createInfoCount,
1615 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1616 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001617 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001618 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001619
1620 if (pCreateInfos != nullptr) {
1621 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001622 bool has_dynamic_viewport = false;
1623 bool has_dynamic_scissor = false;
1624 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001625 bool has_dynamic_depth_bias = false;
1626 bool has_dynamic_blend_constant = false;
1627 bool has_dynamic_depth_bounds = false;
1628 bool has_dynamic_stencil_compare = false;
1629 bool has_dynamic_stencil_write = false;
1630 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001631 bool has_dynamic_viewport_w_scaling_nv = false;
1632 bool has_dynamic_discard_rectangle_ext = false;
1633 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001634 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001635 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001636 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001637 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001638 bool has_dynamic_cull_mode = false;
1639 bool has_dynamic_front_face = false;
1640 bool has_dynamic_primitive_topology = false;
1641 bool has_dynamic_viewport_with_count = false;
1642 bool has_dynamic_scissor_with_count = false;
1643 bool has_dynamic_vertex_input_binding_stride = false;
1644 bool has_dynamic_depth_test_enable = false;
1645 bool has_dynamic_depth_write_enable = false;
1646 bool has_dynamic_depth_compare_op = false;
1647 bool has_dynamic_depth_bounds_test_enable = false;
1648 bool has_dynamic_stencil_test_enable = false;
1649 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001650 bool has_patch_control_points = false;
1651 bool has_rasterizer_discard_enable = false;
1652 bool has_depth_bias_enable = false;
1653 bool has_logic_op = false;
1654 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001655 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001656 if (pCreateInfos[i].pDynamicState != nullptr) {
1657 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1658 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1659 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001660 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1661 if (has_dynamic_viewport == true) {
1662 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1663 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001664 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001665 i);
1666 }
1667 has_dynamic_viewport = true;
1668 }
1669 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1670 if (has_dynamic_scissor == true) {
1671 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1672 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001673 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001674 i);
1675 }
1676 has_dynamic_scissor = true;
1677 }
1678 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1679 if (has_dynamic_line_width == true) {
1680 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1681 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001682 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001683 i);
1684 }
1685 has_dynamic_line_width = true;
1686 }
1687 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1688 if (has_dynamic_depth_bias == true) {
1689 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1690 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001691 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001692 i);
1693 }
1694 has_dynamic_depth_bias = true;
1695 }
1696 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1697 if (has_dynamic_blend_constant == true) {
1698 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1699 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001700 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001701 i);
1702 }
1703 has_dynamic_blend_constant = true;
1704 }
1705 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1706 if (has_dynamic_depth_bounds == true) {
1707 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1708 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001709 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001710 i);
1711 }
1712 has_dynamic_depth_bounds = true;
1713 }
1714 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1715 if (has_dynamic_stencil_compare == true) {
1716 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1717 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001718 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001719 i);
1720 }
1721 has_dynamic_stencil_compare = true;
1722 }
1723 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1724 if (has_dynamic_stencil_write == true) {
1725 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1726 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001727 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001728 i);
1729 }
1730 has_dynamic_stencil_write = true;
1731 }
1732 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1733 if (has_dynamic_stencil_reference == true) {
1734 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1735 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001736 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001737 i);
1738 }
1739 has_dynamic_stencil_reference = true;
1740 }
1741 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1742 if (has_dynamic_viewport_w_scaling_nv == true) {
1743 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1744 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001745 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001746 i);
1747 }
1748 has_dynamic_viewport_w_scaling_nv = true;
1749 }
1750 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1751 if (has_dynamic_discard_rectangle_ext == true) {
1752 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1753 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001754 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001755 i);
1756 }
1757 has_dynamic_discard_rectangle_ext = true;
1758 }
1759 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1760 if (has_dynamic_sample_locations_ext == true) {
1761 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1762 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001763 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001764 i);
1765 }
1766 has_dynamic_sample_locations_ext = true;
1767 }
1768 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1769 if (has_dynamic_exclusive_scissor_nv == true) {
1770 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1771 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001772 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001773 i);
1774 }
1775 has_dynamic_exclusive_scissor_nv = true;
1776 }
1777 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1778 if (has_dynamic_shading_rate_palette_nv == true) {
1779 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1780 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001781 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001782 i);
1783 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001784 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001785 }
1786 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1787 if (has_dynamic_viewport_course_sample_order_nv == true) {
1788 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1789 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001790 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001791 i);
1792 }
1793 has_dynamic_viewport_course_sample_order_nv = true;
1794 }
1795 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1796 if (has_dynamic_line_stipple == true) {
1797 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1798 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001799 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001800 i);
1801 }
1802 has_dynamic_line_stipple = true;
1803 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001804 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1805 if (has_dynamic_cull_mode) {
1806 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1807 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001808 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001809 i);
1810 }
1811 has_dynamic_cull_mode = true;
1812 }
1813 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1814 if (has_dynamic_front_face) {
1815 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1816 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001817 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001818 i);
1819 }
1820 has_dynamic_front_face = true;
1821 }
1822 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1823 if (has_dynamic_primitive_topology) {
1824 skip |= LogError(
1825 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1826 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001827 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001828 i);
1829 }
1830 has_dynamic_primitive_topology = true;
1831 }
1832 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1833 if (has_dynamic_viewport_with_count) {
1834 skip |= LogError(
1835 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1836 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001837 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001838 i);
1839 }
1840 has_dynamic_viewport_with_count = true;
1841 }
1842 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1843 if (has_dynamic_scissor_with_count) {
1844 skip |= LogError(
1845 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1846 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001847 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001848 i);
1849 }
1850 has_dynamic_scissor_with_count = true;
1851 }
1852 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1853 if (has_dynamic_vertex_input_binding_stride) {
1854 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1855 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1856 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001857 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001858 i);
1859 }
1860 has_dynamic_vertex_input_binding_stride = true;
1861 }
1862 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1863 if (has_dynamic_depth_test_enable) {
1864 skip |= LogError(
1865 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1866 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001867 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001868 i);
1869 }
1870 has_dynamic_depth_test_enable = true;
1871 }
1872 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1873 if (has_dynamic_depth_write_enable) {
1874 skip |= LogError(
1875 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1876 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001877 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001878 i);
1879 }
1880 has_dynamic_depth_write_enable = true;
1881 }
1882 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1883 if (has_dynamic_depth_compare_op) {
1884 skip |=
1885 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1886 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001887 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001888 i);
1889 }
1890 has_dynamic_depth_compare_op = true;
1891 }
1892 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1893 if (has_dynamic_depth_bounds_test_enable) {
1894 skip |= LogError(
1895 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1896 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001897 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001898 i);
1899 }
1900 has_dynamic_depth_bounds_test_enable = true;
1901 }
1902 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1903 if (has_dynamic_stencil_test_enable) {
1904 skip |= LogError(
1905 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1906 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001907 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001908 i);
1909 }
1910 has_dynamic_stencil_test_enable = true;
1911 }
1912 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1913 if (has_dynamic_stencil_op) {
1914 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1915 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001916 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001917 i);
1918 }
1919 has_dynamic_stencil_op = true;
1920 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001921 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1922 // Not allowed for graphics pipelines
1923 skip |= LogError(
1924 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1925 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001926 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
1927 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001928 i, state_index);
1929 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001930 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1931 if (has_patch_control_points) {
1932 skip |= LogError(
1933 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1934 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001935 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001936 i);
1937 }
1938 has_patch_control_points = true;
1939 }
1940 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1941 if (has_rasterizer_discard_enable) {
1942 skip |= LogError(
1943 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1944 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001945 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001946 i);
1947 }
1948 has_rasterizer_discard_enable = true;
1949 }
1950 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1951 if (has_depth_bias_enable) {
1952 skip |= LogError(
1953 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1954 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001955 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001956 i);
1957 }
1958 has_depth_bias_enable = true;
1959 }
1960 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1961 if (has_logic_op) {
1962 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1963 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001964 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001965 i);
1966 }
1967 has_logic_op = true;
1968 }
1969 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1970 if (has_primitive_restart_enable) {
1971 skip |= LogError(
1972 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1973 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001974 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001975 i);
1976 }
1977 has_primitive_restart_enable = true;
1978 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001979 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1980 if (has_dynamic_vertex_input) {
1981 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001982 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1983 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
1984 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06001985 }
1986 has_dynamic_vertex_input = true;
1987 }
Petr Kraus299ba622017-11-24 03:09:03 +01001988 }
1989 }
1990
sfricke-samsung3b944422021-01-23 02:15:19 -08001991 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1992 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1993 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001994 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
1995 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08001996 i);
1997 }
1998
1999 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2000 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2001 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002002 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002003 i);
2004 }
2005
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002006 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002007 if ((feedback_struct != nullptr) &&
2008 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002009 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
2010 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2011 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2012 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
2013 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002014 }
2015
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002016 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002017
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002018 // Collect active stages and other information
2019 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002020 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002021 bool has_eval = false;
2022 bool has_control = false;
2023 if (pCreateInfos[i].pStages != nullptr) {
2024 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
2025 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
2026
2027 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
2028 has_control = true;
2029 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
2030 has_eval = true;
2031 }
2032
2033 skip |= validate_string(
2034 "vkCreateGraphicsPipelines",
2035 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2036 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002037
2038 std::stringstream msg;
2039 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2040 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2041 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002042 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002043 }
2044
2045 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2046 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2047 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2048 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2049 pCreateInfos[i].pTessellationState,
2050 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2051 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2052
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002053 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002054 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2055
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002056 skip |= validate_struct_pnext(
2057 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2058 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2059 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2060 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2061 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2062 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002063
2064 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2065 pCreateInfos[i].pTessellationState->flags,
2066 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2067 }
2068
2069 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2070 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2071 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2072 pCreateInfos[i].pInputAssemblyState,
2073 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2074 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2075
2076 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2077 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002078 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002079
2080 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2081 pCreateInfos[i].pInputAssemblyState->flags,
2082 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2083
2084 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2085 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2086 pCreateInfos[i].pInputAssemblyState->topology,
2087 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2088
2089 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2090 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2091 }
2092
2093 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002094 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002095
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002096 if (pCreateInfos[i].pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002097 skip |=
2098 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2099 "vkCreateGraphicsPipelines: pararameter "
2100 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2101 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002102 }
2103
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002104 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002105 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2106 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2107 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2108 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002109 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2110 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002111 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002112 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2113 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002114 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002115 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2116 skip |=
2117 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2118 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2119 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2120 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2121 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2122
2123 skip |= validate_array(
2124 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2125 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2126 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2127 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2128
2129 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002130 for (uint32_t vertex_binding_description_index = 0;
2131 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2132 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002133 skip |= validate_ranged_enum(
2134 "vkCreateGraphicsPipelines",
2135 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2136 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002137 pCreateInfos[i]
2138 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2139 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002140 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2141 }
2142 }
2143
2144 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002145 for (uint32_t vertex_attribute_description_index = 0;
2146 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2147 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002148 const VkFormat format =
2149 pCreateInfos[i]
2150 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2151 .format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002152 skip |= validate_ranged_enum(
2153 "vkCreateGraphicsPipelines",
2154 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2155 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002156 pCreateInfos[i]
2157 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2158 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002159 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002160 if (FormatIsDepthOrStencil(format)) {
2161 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2162 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2163 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2164 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002165 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2166 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002167 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2168 "alignment, replace with a color format.",
2169 i, vertex_attribute_description_index, string_VkFormat(format));
2170 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002171 }
2172 }
2173
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002174 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002175 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2176 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002177 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2178 ") is "
2179 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002180 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002181 }
2182
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002183 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002184 skip |=
2185 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2186 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002187 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2188 ") is "
2189 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002190 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002191 }
2192
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002193 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002194 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2195 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002196 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2197 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002198 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2199 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002200 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2201 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002202 "(%" PRIu32 ") is not distinct.",
2203 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002204 }
2205 vertex_bindings.insert(vertex_bind_desc.binding);
2206
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002207 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002208 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2209 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002210 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2211 "].binding (%" PRIu32
2212 ") is "
2213 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002214 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002215 }
2216
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002217 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002218 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2219 "vkCreateGraphicsPipelines: parameter "
2220 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2221 "].stride (%" PRIu32
2222 ") is greater "
2223 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2224 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002225 }
2226 }
2227
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002228 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002229 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2230 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002231 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2232 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002233 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2234 "vkCreateGraphicsPipelines: parameter "
2235 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2236 "].location (%" PRIu32 ") is not distinct.",
2237 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002238 }
2239 attribute_locations.insert(vertex_attrib_desc.location);
2240
2241 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2242 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002243 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2244 "vkCreateGraphicsPipelines: parameter "
2245 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2246 "].binding (%" PRIu32
2247 ") does not exist "
2248 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2249 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002250 }
2251
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002252 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002253 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2254 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002255 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2256 "].location (%" PRIu32
2257 ") is "
2258 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002259 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002260 }
2261
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002262 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002263 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2264 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002265 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2266 "].binding (%" PRIu32
2267 ") is "
2268 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002269 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270 }
2271
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002272 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002273 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2274 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002275 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2276 "].offset (%" PRIu32
2277 ") is "
2278 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002279 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002280 }
2281 }
2282 }
2283
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002284 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2285 if (has_control && has_eval) {
2286 if (pCreateInfos[i].pTessellationState == nullptr) {
2287 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002288 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2289 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002290 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002291 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002292 i, i);
2293 } else {
2294 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2295 skip |= validate_struct_pnext(
2296 "vkCreateGraphicsPipelines",
2297 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2298 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2299 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2300 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002301
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002302 skip |= validate_reserved_flags(
2303 "vkCreateGraphicsPipelines",
2304 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2305 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002306
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002307 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2308 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2309 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2310 "vkCreateGraphicsPipelines: invalid parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002311 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2312 ". patchControlPoints "
2313 "should be >0 and <=%" PRIu32 ".",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002314 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2315 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002316 }
2317 }
2318 }
2319
2320 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2321 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2322 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2323 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002324 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2325 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2326 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2327 "].pViewportState (=NULL) is not a valid pointer.",
2328 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002329 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002330 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2331
2332 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002333 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2334 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2335 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2336 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002337 }
2338
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002339 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002340 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002341 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2342 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002343 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2344 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002345 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002346 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002347 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002348 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002349 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002350 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2351 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002352 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2353 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2354 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002355 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002356
2357 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002358 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002359 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002360 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002361
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002362 auto exclusive_scissor_struct =
2363 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2364 auto shading_rate_image_struct =
2365 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2366 auto coarse_sample_order_struct =
2367 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002368 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002369 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002370 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002371 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002372
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002373 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002374 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002375 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2376 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2377 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2378 ") is not 1.",
2379 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002380 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002381
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002382 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002383 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2384 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2385 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2386 ") is not 1.",
2387 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002388 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002389
Dave Houlton142c4cb2018-10-17 15:04:41 -06002390 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2391 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002392 skip |= LogError(
2393 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2394 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2395 "disabled, but pCreateInfos[%" PRIu32
2396 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2397 ") is not 1.",
2398 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002399 }
2400
Jeff Bolz9af91c52018-09-01 21:53:57 -05002401 if (shading_rate_image_struct &&
2402 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002403 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2404 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2405 "disabled, but pCreateInfos[%" PRIu32
2406 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2407 ") is neither 0 nor 1.",
2408 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002409 }
2410
Petr Krausa6103552017-11-16 21:21:58 +01002411 } else { // multiViewport enabled
2412 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002413 if (!has_dynamic_viewport_with_count) {
2414 skip |= LogError(
2415 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2416 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2417 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002418 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002419 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2420 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2421 "].pViewportState->viewportCount (=%" PRIu32
2422 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2423 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002424 } else if (has_dynamic_viewport_with_count) {
2425 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2426 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2427 "].pViewportState->viewportCount (=%" PRIu32
2428 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2429 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002430 }
Petr Krausa6103552017-11-16 21:21:58 +01002431
2432 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002433 if (!has_dynamic_scissor_with_count) {
2434 skip |= LogError(
2435 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2436 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2437 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002438 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002439 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2440 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2441 "].pViewportState->scissorCount (=%" PRIu32
2442 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2443 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002444 } else if (has_dynamic_scissor_with_count) {
2445 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2446 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2447 "].pViewportState->scissorCount (=%" PRIu32
2448 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2449 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002450 }
2451 }
2452
ziga-lunarg845883b2021-07-14 15:05:00 +02002453 if (!has_dynamic_scissor && viewport_state.pScissors) {
2454 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2455 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002456
2457 if (scissor.offset.x < 0) {
2458 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2459 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2460 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2461 scissor.offset.x, i, scissor_i);
2462 }
2463
2464 if (scissor.offset.y < 0) {
2465 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2466 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2467 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2468 scissor.offset.y, i, scissor_i);
2469 }
2470
ziga-lunarg845883b2021-07-14 15:05:00 +02002471 const int64_t x_sum =
2472 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2473 if (x_sum > std::numeric_limits<int32_t>::max()) {
2474 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2475 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2476 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2477 "] will overflow int32_t.",
2478 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2479 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002480
ziga-lunarg845883b2021-07-14 15:05:00 +02002481 const int64_t y_sum =
2482 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2483 if (y_sum > std::numeric_limits<int32_t>::max()) {
2484 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2485 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2486 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2487 "] will overflow int32_t.",
2488 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2489 }
2490 }
2491 }
2492
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002493 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002494 skip |=
2495 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2496 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2497 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2498 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002499 }
2500
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002501 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002502 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2503 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2504 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2505 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2506 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002507 }
2508
Piers Daniell39842ee2020-07-10 16:42:33 -06002509 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2510 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002511 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2512 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2513 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2514 "].pViewportState->viewportCount (=%" PRIu32 ").",
2515 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002516 }
2517
Dave Houlton142c4cb2018-10-17 15:04:41 -06002518 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002519 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002520 skip |=
2521 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2522 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2523 ") must be zero or identical to pCreateInfos[%" PRIu32
2524 "].pViewportState->viewportCount (=%" PRIu32 ").",
2525 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002526 }
2527
Dave Houlton142c4cb2018-10-17 15:04:41 -06002528 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002529 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002530 skip |= LogError(
2531 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002532 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2533 "] "
2534 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2535 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2536 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002537 }
2538
Petr Krausa6103552017-11-16 21:21:58 +01002539 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002540 skip |= LogError(
2541 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002542 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2543 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002544 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2545 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002546 }
2547
2548 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002549 skip |= LogError(
2550 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002551 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2552 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002553 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2554 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002555 }
2556
Jeff Bolz3e71f782018-08-29 23:15:45 -05002557 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002558 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2559 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2560 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002561 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002562 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2563 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2564 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2565 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002566 }
2567
Jeff Bolz9af91c52018-09-01 21:53:57 -05002568 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002569 shading_rate_image_struct->viewportCount > 0 &&
2570 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002571 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002572 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002573 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002574 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2575 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002576 i, i);
2577 }
2578
Chris Mayer328d8212018-12-11 14:16:18 +01002579 if (vp_swizzle_struct) {
2580 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002581 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2582 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2583 " does "
2584 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2585 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002586 }
2587 }
2588
Petr Krausb3fcdb42018-01-09 22:09:09 +01002589 // validate the VkViewports
2590 if (!has_dynamic_viewport && viewport_state.pViewports) {
2591 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2592 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002593 const char *fn_name = "vkCreateGraphicsPipelines";
2594 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2595 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2596 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002597 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002598 }
2599 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002600
sfricke-samsung45996a42021-09-16 13:45:27 -07002601 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002602 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2603 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2604 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2605 "VK_NV_clip_space_w_scaling extension is not enabled.",
2606 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002607 }
2608
sfricke-samsung45996a42021-09-16 13:45:27 -07002609 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002610 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2611 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2612 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2613 "VK_EXT_discard_rectangles extension is not enabled.",
2614 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002615 }
2616
sfricke-samsung45996a42021-09-16 13:45:27 -07002617 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002618 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2619 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2620 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2621 "VK_EXT_sample_locations extension is not enabled.",
2622 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002623 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002624
sfricke-samsung45996a42021-09-16 13:45:27 -07002625 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002626 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2627 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2628 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2629 "VK_NV_scissor_exclusive extension is not enabled.",
2630 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002631 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002632
2633 if (coarse_sample_order_struct &&
2634 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2635 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002636 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2637 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2638 "] "
2639 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2640 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2641 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002642 }
2643
2644 if (coarse_sample_order_struct) {
2645 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002646 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002647 }
2648 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002649
2650 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2651 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002652 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2653 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2654 "] "
2655 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2656 ") "
2657 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2658 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002659 }
2660 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002661 skip |= LogError(
2662 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002663 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2664 "] "
2665 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2666 i);
2667 }
2668 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002669 }
2670
2671 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002672 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002673 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2674 "].pRasterizationState->rasterizerDiscardEnable "
2675 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002676 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002677 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002678 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002679 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002680 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2681 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002682 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002683 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002684 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002685 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002686 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002687 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002688 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002689 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2690 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002691
2692 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002693 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002694 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002695 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002696
2697 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002698 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002699 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2700 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2701
2702 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002703 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002704 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2705 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002706 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002707 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002709 skip |= validate_flags(
2710 "vkCreateGraphicsPipelines",
2711 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2712 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002713 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002714
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002715 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002716 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002717 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2718 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2719
2720 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002721 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002722 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2723 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2724
2725 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002726 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002727 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2728 "].pMultisampleState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002729 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2730 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002731 }
John Zulauf7acac592017-11-06 11:15:53 -07002732 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002733 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002734 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2735 "vkCreateGraphicsPipelines(): parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002736 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002737 i);
John Zulauf7acac592017-11-06 11:15:53 -07002738 }
2739 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2740 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2741 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002742 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002743
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002744 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2745 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2746 "].pMultisampleState->minSampleShading.",
2747 i);
John Zulauf7acac592017-11-06 11:15:53 -07002748 }
2749 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002750
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002751 const auto *line_state =
2752 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002753
2754 if (line_state) {
2755 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2756 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2757 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2758 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002759 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2760 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002761 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002762 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002763 }
2764 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2765 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002766 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2767 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002768 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002769 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002770 }
2771 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2772 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002773 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2774 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002775 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002776 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002777 }
2778 }
2779 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2780 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2781 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002782 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002783 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
2784 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002785 "range [1,256].",
2786 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002787 }
2788 }
2789 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002790 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002791 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2792 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002793 skip |=
2794 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002795 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2796 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002797 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2798 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002799 }
2800 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2801 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002802 skip |=
2803 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002804 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2805 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002806 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2807 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002808 }
2809 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2810 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002811 skip |=
2812 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002813 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2814 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002815 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2816 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002817 }
2818 if (line_state->stippledLineEnable) {
2819 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2820 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002821 skip |=
2822 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002823 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2824 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002825 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2826 "stippledRectangularLines feature.",
2827 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002828 }
2829 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2830 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002831 skip |=
2832 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002833 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2834 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002835 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2836 "stippledBresenhamLines feature.",
2837 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002838 }
2839 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2840 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002841 skip |=
2842 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002843 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2844 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002845 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2846 "stippledSmoothLines feature.",
2847 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002848 }
2849 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2850 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002851 skip |=
2852 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002853 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2854 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002855 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2856 "stippledRectangularLines and strictLines features.",
2857 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002858 }
2859 }
2860 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002861 }
2862
Petr Krause91f7a12017-12-14 20:57:36 +01002863 bool uses_color_attachment = false;
2864 bool uses_depthstencil_attachment = false;
2865 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002866 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002867 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2868 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002869 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002870 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002871 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002872 }
2873 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002874 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002875 }
Petr Krause91f7a12017-12-14 20:57:36 +01002876 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002877 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002878 }
2879
2880 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002881 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002882 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002883 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002884 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002885 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002886
2887 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002888 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002889 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002890 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002891
2892 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002893 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2895 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2896
2897 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002898 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002899 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2900 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2901
2902 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002903 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002904 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2905 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002906 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002907
2908 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002909 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002910 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2911 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2912
2913 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002914 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002915 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2916 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2917
2918 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002919 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002920 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2921 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002922 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002923
2924 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002925 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002926 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2927 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002928 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002929
2930 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002931 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002932 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2933 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002934 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002935
2936 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002937 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002938 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2939 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002940 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002941
2942 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002943 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2945 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002946 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002947
2948 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002949 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002950 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2951 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002952 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953
2954 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002955 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2957 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002958 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002959
2960 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002961 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2963 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002964 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965
2966 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002967 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002968 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2969 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002970 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2971 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002972 }
2973 }
2974
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002975 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02002976 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
2977 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002978
Petr Krause91f7a12017-12-14 20:57:36 +01002979 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002980 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2981 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2982 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2983 pCreateInfos[i].pColorBlendState,
2984 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2985 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2986
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002988 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002989 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
ziga-lunarg8de09162021-08-05 15:21:33 +02002990 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002991 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2992 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002993 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2994 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995
2996 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002997 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002998 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002999 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000
3001 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003002 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
3004 pCreateInfos[i].pColorBlendState->logicOpEnable);
3005
3006 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003007 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003008 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3009 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00003010 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06003011 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003012
3013 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003014 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
3015 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003016 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003017 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003018 ParameterName::IndexVector{i, attachment_index}),
3019 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003020
3021 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003022 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003023 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003024 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003025 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003026 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003027 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003028
3029 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003030 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003031 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003032 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003033 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003034 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003035 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003036
3037 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003038 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003039 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003040 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003041 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003042 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003043 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003044
3045 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003046 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003047 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003048 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003049 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003050 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003051 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003052
3053 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003054 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003055 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003056 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003057 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003058 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003059 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003060
3061 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003062 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003063 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003064 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003065 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003066 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003067 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003068
3069 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003070 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003071 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003072 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003073 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003074 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003075 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003076
3077 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3078 bool invalid = false;
3079 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3080 case VK_BLEND_OP_ZERO_EXT:
3081 case VK_BLEND_OP_SRC_EXT:
3082 case VK_BLEND_OP_DST_EXT:
3083 case VK_BLEND_OP_SRC_OVER_EXT:
3084 case VK_BLEND_OP_DST_OVER_EXT:
3085 case VK_BLEND_OP_SRC_IN_EXT:
3086 case VK_BLEND_OP_DST_IN_EXT:
3087 case VK_BLEND_OP_SRC_OUT_EXT:
3088 case VK_BLEND_OP_DST_OUT_EXT:
3089 case VK_BLEND_OP_SRC_ATOP_EXT:
3090 case VK_BLEND_OP_DST_ATOP_EXT:
3091 case VK_BLEND_OP_XOR_EXT:
3092 case VK_BLEND_OP_INVERT_EXT:
3093 case VK_BLEND_OP_INVERT_RGB_EXT:
3094 case VK_BLEND_OP_LINEARDODGE_EXT:
3095 case VK_BLEND_OP_LINEARBURN_EXT:
3096 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3097 case VK_BLEND_OP_LINEARLIGHT_EXT:
3098 case VK_BLEND_OP_PINLIGHT_EXT:
3099 case VK_BLEND_OP_HARDMIX_EXT:
3100 case VK_BLEND_OP_PLUS_EXT:
3101 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3102 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3103 case VK_BLEND_OP_PLUS_DARKER_EXT:
3104 case VK_BLEND_OP_MINUS_EXT:
3105 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3106 case VK_BLEND_OP_CONTRAST_EXT:
3107 case VK_BLEND_OP_INVERT_OVG_EXT:
3108 case VK_BLEND_OP_RED_EXT:
3109 case VK_BLEND_OP_GREEN_EXT:
3110 case VK_BLEND_OP_BLUE_EXT:
3111 invalid = true;
3112 break;
3113 default:
3114 break;
3115 }
3116 if (invalid) {
3117 skip |= LogError(
3118 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3119 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3120 "].pColorBlendState->pAttachments[%" PRIu32
3121 "].colorBlendOp (%s) is not valid when "
3122 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3123 "VK_FALSE",
3124 i, attachment_index,
3125 string_VkBlendOp(
3126 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3127 }
3128 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003129 }
3130 }
3131
3132 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003133 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003134 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3135 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003136 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3137 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003138 }
3139
3140 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3141 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3142 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003143 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003144 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003145 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3146 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003147 }
3148 }
3149 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003150
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003151 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3152 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003153 if (pCreateInfos[i].basePipelineIndex != -1) {
3154 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003155 skip |=
3156 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003157 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3158 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003159 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003160 "and pCreateInfos->basePipelineIndex is not -1.",
3161 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003162 }
3163 }
3164
Petr Kraus9752aae2017-11-24 03:05:50 +01003165 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3166 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003167 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003168 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3169 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003170 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003171 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3172 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003173 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003174 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003175 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003176 skip |=
3177 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003178 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3179 ") must be a valid"
3180 "index into the pCreateInfos array, of size %" PRIu32 ".",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003181 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003182 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003183 }
3184 }
3185
Petr Kraus9752aae2017-11-24 03:05:50 +01003186 if (pCreateInfos[i].pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003187 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003188 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3189 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003190 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3191 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3192 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3193 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003194 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3195 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003196 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003197 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003198 "pCreateInfos[%" PRIu32
3199 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003200 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3201 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003202 }
3203 } else {
3204 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3205 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3206 (physical_device_features.fillModeNonSolid == false)) {
3207 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003208 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3209 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003210 "pCreateInfos[%" PRIu32
3211 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003212 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3213 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003214 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003215 }
Petr Kraus299ba622017-11-24 03:09:03 +01003216
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003217 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003218 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003219 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3220 "The line width state is static (pCreateInfos[%" PRIu32
3221 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3222 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3223 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3224 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003225 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003226 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003227
3228 // Validate no flags not allowed are used
3229 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003230 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003231 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3232 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003233 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3234 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003235 }
3236 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003237 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003238 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3239 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003240 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3241 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003242 }
3243 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3244 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003245 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3246 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003247 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3248 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003249 }
3250 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3251 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003252 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3253 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003254 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3255 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003256 }
3257 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3258 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003259 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3260 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003261 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3262 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003263 }
3264 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3265 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003266 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3267 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003268 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3269 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003270 }
3271 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3272 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003273 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3274 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003275 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3276 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003277 }
3278 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3279 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003280 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3281 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003282 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3283 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003284 }
3285 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3286 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003287 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3288 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003289 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3290 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003291 }
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,
4129 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004130 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004131 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4132 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4133 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4134 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004135
Tony-LunarG3c287f62020-12-17 12:39:49 -07004136 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004137
Tony-LunarG3c287f62020-12-17 12:39:49 -07004138 // Explicit VUs
4139 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004140 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004141 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4142 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4143 cmd_name);
4144 }
4145
4146 if (physical_device_features.inheritedQueries) {
4147 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004148 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4149 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4150 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004151 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004152 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004153 }
4154
4155 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004156 skip |=
4157 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4158 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4159 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4160 } else { // !pipelineStatisticsQuery
4161 skip |=
4162 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4163 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004164 }
4165
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004166 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004167 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004168 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004169 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4170 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4171 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004172 commandBuffer,
4173 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004174 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4175 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4176 }
Petr Kraus139757b2019-08-15 17:19:33 +02004177 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004178
4179 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4180 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4181 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4182 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4183 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4184 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4185 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4186 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4187 }
Petr Kraus139757b2019-08-15 17:19:33 +02004188 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004189 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004190 return skip;
4191}
4192
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004193bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004194 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004195 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004196
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004197 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004198 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004199 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4200 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4201 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004202 }
4203 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004204 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4205 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4206 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004207 }
4208 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004209 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004210 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004211 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4212 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4213 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4214 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004215 }
4216 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004217
4218 if (pViewports) {
4219 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4220 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004221 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004222 skip |= manual_PreCallValidateViewport(
4223 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004224 }
4225 }
4226
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004227 return skip;
4228}
4229
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004230bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004231 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004232 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004233
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004234 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004235 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004236 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4237 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4238 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004239 }
4240 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004241 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4242 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4243 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004244 }
4245 } else { // multiViewport enabled
4246 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004247 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004248 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4249 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4250 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4251 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004252 }
4253 }
4254
Petr Kraus6260f0a2018-02-27 21:15:55 +01004255 if (pScissors) {
4256 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4257 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004258
Petr Kraus6260f0a2018-02-27 21:15:55 +01004259 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004260 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4261 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4262 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004263 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004264
Petr Kraus6260f0a2018-02-27 21:15:55 +01004265 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004266 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4267 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4268 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004269 }
4270
4271 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4272 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004273 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4274 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4275 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4276 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004277 }
4278
4279 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4280 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004281 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4282 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4283 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4284 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004285 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004286 }
4287 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004288
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004289 return skip;
4290}
4291
Jeff Bolz5c801d12019-10-09 10:38:45 -05004292bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004293 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004294
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004295 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004296 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4297 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004298 }
4299
4300 return skip;
4301}
4302
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004303bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004304 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004305 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004306
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004307 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004308 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004309 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4310 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004311 }
4312 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004313 skip |=
4314 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4315 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4316 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004317 }
4318 return skip;
4319}
4320
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004321bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004322 VkDeviceSize offset, uint32_t drawCount,
4323 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004324 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004325 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004326 skip |=
4327 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4328 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4329 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004330 }
4331 if (drawCount > device_limits.maxDrawIndirectCount) {
4332 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004333 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4334 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004335 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004336 }
4337 return skip;
4338}
4339
sfricke-samsungf692b972020-05-02 08:00:45 -07004340bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4341 VkDeviceSize countBufferOffset, bool khr) const {
4342 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004343 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004344 if (offset & 3) {
4345 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004346 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004347 }
4348
4349 if (countBufferOffset & 3) {
4350 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004351 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004352 countBufferOffset);
4353 }
4354 return skip;
4355}
4356
4357bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4358 VkDeviceSize offset, VkBuffer countBuffer,
4359 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4360 uint32_t stride) const {
4361 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4362}
4363
4364bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4365 VkDeviceSize offset, VkBuffer countBuffer,
4366 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4367 uint32_t stride) const {
4368 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4369}
4370
4371bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4372 VkDeviceSize countBufferOffset, bool khr) const {
4373 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004374 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004375 if (offset & 3) {
4376 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004377 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004378 }
4379
4380 if (countBufferOffset & 3) {
4381 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004382 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004383 countBufferOffset);
4384 }
4385 return skip;
4386}
4387
4388bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4389 VkDeviceSize offset, VkBuffer countBuffer,
4390 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4391 uint32_t stride) const {
4392 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4393}
4394
4395bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4396 VkDeviceSize offset, VkBuffer countBuffer,
4397 VkDeviceSize countBufferOffset,
4398 uint32_t maxDrawCount, uint32_t stride) const {
4399 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4400}
4401
Tony-LunarG4490de42021-06-21 15:49:19 -06004402bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4403 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4404 uint32_t firstInstance, uint32_t stride) const {
4405 bool skip = false;
4406 if (stride & 3) {
4407 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4408 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4409 }
4410 if (drawCount && nullptr == pVertexInfo) {
4411 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4412 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4413 "one or more valid instances of VkMultiDrawInfoEXT structures");
4414 }
4415 return skip;
4416}
4417
4418bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4419 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4420 uint32_t instanceCount, uint32_t firstInstance,
4421 uint32_t stride, const int32_t *pVertexOffset) const {
4422 bool skip = false;
4423 if (stride & 3) {
4424 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4425 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4426 }
4427 if (drawCount && nullptr == pIndexInfo) {
4428 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4429 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4430 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4431 }
4432 return skip;
4433}
4434
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004435bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4436 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004437 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004438 bool skip = false;
4439 for (uint32_t rect = 0; rect < rectCount; rect++) {
4440 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004441 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004442 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004443 }
sfricke-samsung10867682020-04-25 02:20:39 -07004444 if (pRects[rect].rect.extent.width == 0) {
4445 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004446 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004447 }
4448 if (pRects[rect].rect.extent.height == 0) {
4449 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004450 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004451 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004452 }
4453 return skip;
4454}
4455
Andrew Fobel3abeb992020-01-20 16:33:22 -05004456bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4457 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4458 VkImageFormatProperties2 *pImageFormatProperties,
4459 const char *apiName) const {
4460 bool skip = false;
4461
4462 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004463 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004464 if (image_stencil_struct != nullptr) {
4465 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4466 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4467 // No flags other than the legal attachment bits may be set
4468 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4469 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004470 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4471 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4472 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4473 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4474 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004475 }
4476 }
4477 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004478 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4479 if (image_drm_format) {
4480 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4481 skip |= LogError(
4482 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4483 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4484 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4485 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4486 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004487 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4488 skip |= LogError(
4489 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4490 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4491 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4492 apiName, image_drm_format->queueFamilyIndexCount);
4493 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004494 } else {
4495 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4496 skip |= LogError(
4497 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4498 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4499 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4500 apiName);
4501 }
4502 }
4503 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4504 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4505 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4506 if (!format_list || format_list->viewFormatCount == 0) {
4507 skip |= LogError(
4508 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4509 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4510 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4511 apiName);
4512 }
4513 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004514 }
4515
4516 return skip;
4517}
4518
4519bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4520 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4521 VkImageFormatProperties2 *pImageFormatProperties) const {
4522 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4523 "vkGetPhysicalDeviceImageFormatProperties2");
4524}
4525
4526bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4527 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4528 VkImageFormatProperties2 *pImageFormatProperties) const {
4529 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4530 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4531}
4532
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004533bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4534 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4535 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4536 bool skip = false;
4537
4538 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4539 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4540 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4541 }
4542
4543 return skip;
4544}
4545
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004546bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4547 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4548 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4549 bool skip = false;
4550
4551 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4552 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4553 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4554 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4555 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4556 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4557 }
4558
ziga-lunarg42f884b2021-08-25 16:13:20 +02004559 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004560}
4561
sfricke-samsung3999ef62020-02-09 17:05:59 -08004562bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4563 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4564 bool skip = false;
4565
4566 if (pRegions != nullptr) {
4567 for (uint32_t i = 0; i < regionCount; i++) {
4568 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004569 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004570 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004571 }
4572 }
4573 }
4574 return skip;
4575}
4576
Jeff Leger178b1e52020-10-05 12:22:23 -04004577bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4578 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4579 bool skip = false;
4580
4581 if (pCopyBufferInfo->pRegions != nullptr) {
4582 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4583 if (pCopyBufferInfo->pRegions[i].size == 0) {
4584 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004585 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004586 }
4587 }
4588 }
4589 return skip;
4590}
4591
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004592bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004593 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4594 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004595 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004596
4597 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004598 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4599 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4600 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004601 }
4602
4603 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004604 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4605 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4606 "), must be greater than zero and less than or equal to 65536.",
4607 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004608 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004609 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4610 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4611 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004612 }
4613 return skip;
4614}
4615
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004616bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004617 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004618 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004619
4620 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004621 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4622 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4623 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004624 }
4625
4626 if (size != VK_WHOLE_SIZE) {
4627 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004628 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004629 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4630 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004631 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004632 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4633 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004634 }
4635 }
4636 return skip;
4637}
4638
sfricke-samsunga1d00272021-03-10 21:37:41 -08004639bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004640 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004641
4642 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004643 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4644 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4645 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4646 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004647 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004648 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4649 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4650 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004651 }
4652
4653 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4654 // queueFamilyIndexCount uint32_t values
4655 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004656 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004657 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004658 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004659 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4660 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004661 }
4662 }
4663
Dave Houlton413a6782018-05-22 13:01:54 -06004664 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004665 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004666
sfricke-samsunga1d00272021-03-10 21:37:41 -08004667 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4668 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4669 if (format_list_info) {
4670 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4671 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4672 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4673 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004674 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
4675 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004676 func_name, viewFormatCount);
4677 }
4678
4679 // Using the first format, compare the rest of the formats against it that they are compatible
4680 for (uint32_t i = 1; i < viewFormatCount; i++) {
4681 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4682 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4683 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4684 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004685 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
4686 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004687 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4688 string_VkFormat(format_list_info->pViewFormats[i]));
4689 }
4690 }
4691 }
4692
4693 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4694 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4695 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4696 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4697 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4698 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4699 func_name);
4700 } else {
4701 if (format_list_info == nullptr) {
4702 skip |= LogError(
4703 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4704 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4705 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4706 func_name);
4707 } else if (format_list_info->viewFormatCount == 0) {
4708 skip |= LogError(
4709 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4710 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4711 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4712 func_name);
4713 } else {
4714 bool found_base_format = false;
4715 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4716 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4717 found_base_format = true;
4718 break;
4719 }
4720 }
4721 if (!found_base_format) {
4722 skip |=
4723 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4724 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4725 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4726 "pCreateInfo->imageFormat.",
4727 func_name);
4728 }
4729 }
4730 }
4731 }
4732 }
4733 return skip;
4734}
4735
4736bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4737 const VkAllocationCallbacks *pAllocator,
4738 VkSwapchainKHR *pSwapchain) const {
4739 bool skip = false;
4740 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4741 return skip;
4742}
4743
4744bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4745 const VkSwapchainCreateInfoKHR *pCreateInfos,
4746 const VkAllocationCallbacks *pAllocator,
4747 VkSwapchainKHR *pSwapchains) const {
4748 bool skip = false;
4749 if (pCreateInfos) {
4750 for (uint32_t i = 0; i < swapchainCount; i++) {
4751 std::stringstream func_name;
4752 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4753 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4754 }
4755 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004756 return skip;
4757}
4758
Jeff Bolz5c801d12019-10-09 10:38:45 -05004759bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004760 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004761
4762 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004763 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004764 if (present_regions) {
4765 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004766 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004767 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4768 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004769 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004770 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4771 "extension swapchainCount is %i. These values must be equal.",
4772 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004773 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004774 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004775 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4776 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004777 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4778 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4779 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004780 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004781 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004782 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004783 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004784 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004785 }
4786 }
4787
4788 return skip;
4789}
4790
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004791bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4792 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4793 const VkAllocationCallbacks *pAllocator,
4794 VkDisplayModeKHR *pMode) const {
4795 bool skip = false;
4796
4797 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4798 if (display_mode_parameters.visibleRegion.width == 0) {
4799 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4800 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4801 }
4802 if (display_mode_parameters.visibleRegion.height == 0) {
4803 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4804 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4805 }
4806 if (display_mode_parameters.refreshRate == 0) {
4807 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4808 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4809 }
4810
4811 return skip;
4812}
4813
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004814#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004815bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4816 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4817 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004818 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004819 bool skip = false;
4820
4821 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004822 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4823 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004824 }
4825
4826 return skip;
4827}
4828#endif // VK_USE_PLATFORM_WIN32_KHR
4829
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004830static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
4831 bool partial_overlap = false;
4832
4833 static const std::vector<VkDescriptorType> all_descriptor_types = {
4834 VK_DESCRIPTOR_TYPE_SAMPLER,
4835 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4836 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
4837 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
4838 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
4839 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
4840 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
4841 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4842 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
4843 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
4844 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
4845 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
4846 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
4847 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
4848 };
4849
4850 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4851 if (mutable_descriptor_type) {
4852 std::vector<VkDescriptorType> first_types, second_types;
4853 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
4854 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
4855 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
4856 }
4857 } else {
4858 first_types = all_descriptor_types;
4859 }
4860 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
4861 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4862 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
4863 }
4864 } else {
4865 second_types = all_descriptor_types;
4866 }
4867
4868 bool complete_overlap = first_types.size() == second_types.size();
4869 bool disjoint = true;
4870 for (const auto first_type : first_types) {
4871 bool found = false;
4872 for (const auto second_type : second_types) {
4873 if (first_type == second_type) {
4874 found = true;
4875 break;
4876 }
4877 }
4878 if (found) {
4879 disjoint = false;
4880 } else {
4881 complete_overlap = false;
4882 }
4883 if (!disjoint && !complete_overlap) {
4884 partial_overlap = true;
4885 break;
4886 }
4887 }
4888 }
4889
4890 return partial_overlap;
4891}
4892
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004893bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004894 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004895 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004896 bool skip = false;
4897
4898 if (pCreateInfo) {
4899 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004900 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4901 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004902 }
4903
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004904 const auto *mutable_descriptor_type_features =
4905 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4906 bool mutable_descriptor_type_enabled =
4907 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4908
Petr Krausc8655be2017-09-27 18:56:51 +02004909 if (pCreateInfo->pPoolSizes) {
4910 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4911 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004912 skip |= LogError(
4913 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004914 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004915 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004916 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4917 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004918 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4919 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4920 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4921 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4922 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004923 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004924 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
4925 skip |=
4926 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
4927 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4928 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
4929 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
4930 i);
4931 }
4932 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4933 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
4934 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4935 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
4936 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
4937 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4938 "].type and pCreateInfo->pPoolSizes[%" PRIu32
4939 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
4940 " and have sets which partially overlap.",
4941 i, j);
4942 }
4943 }
4944 }
4945 }
Petr Krausc8655be2017-09-27 18:56:51 +02004946 }
4947 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004948
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004949 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
4950 skip |=
4951 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
4952 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
4953 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
4954 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004955 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4956 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4957 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4958 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4959 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4960 }
Petr Krausc8655be2017-09-27 18:56:51 +02004961 }
4962
4963 return skip;
4964}
4965
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004966bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004967 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004968 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004969
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004970 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004971 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004972 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4973 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4974 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004975 }
4976
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004977 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004978 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004979 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4980 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4981 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004982 }
4983
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004984 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004985 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004986 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4987 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4988 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004989 }
4990
4991 return skip;
4992}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004993
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004994bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004995 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004996 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004997
4998 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004999 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5000 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005001 }
5002 return skip;
5003}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005004
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005005bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5006 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005007 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005008 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005009
5010 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005011 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005012 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005013 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5014 "vkCmdDispatch(): baseGroupX (%" PRIu32
5015 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5016 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005017 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005018 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5019 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5020 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5021 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005022 }
5023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005024 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005025 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005026 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5027 "vkCmdDispatch(): baseGroupY (%" PRIu32
5028 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5029 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005030 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005031 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5032 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5033 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5034 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005035 }
5036
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005037 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005038 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005039 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5040 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5041 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5042 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005043 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005044 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5045 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5046 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5047 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005048 }
5049
5050 return skip;
5051}
5052
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005053bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5054 VkPipelineBindPoint pipelineBindPoint,
5055 VkPipelineLayout layout, uint32_t set,
5056 uint32_t descriptorWriteCount,
5057 const VkWriteDescriptorSet *pDescriptorWrites) const {
5058 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
5059}
5060
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005061bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5062 uint32_t firstExclusiveScissor,
5063 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005064 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005065 bool skip = false;
5066
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005067 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005068 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005069 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005070 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5071 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5072 ") is not 0.",
5073 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005074 }
5075 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005076 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005077 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5078 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5079 ") is not 1.",
5080 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005081 }
5082 } else { // multiViewport enabled
5083 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005084 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005085 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5086 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5087 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5088 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005089 }
5090 }
5091
Jeff Bolz3e71f782018-08-29 23:15:45 -05005092 if (pExclusiveScissors) {
5093 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5094 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5095
5096 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005097 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5098 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5099 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005100 }
5101
5102 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005103 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5104 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5105 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005106 }
5107
5108 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5109 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005110 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5111 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5112 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5113 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005114 }
5115
5116 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5117 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005118 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5119 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5120 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5121 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005122 }
5123 }
5124 }
5125
5126 return skip;
5127}
5128
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005129bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5130 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005131 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005132 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005133 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5134 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5135 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5136 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5137 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5138 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005139 }
5140
5141 return skip;
5142}
5143
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005144bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5145 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005146 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005147 bool skip = false;
5148
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005149 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005150 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005151 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005152 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5153 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5154 ") is not 0.",
5155 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005156 }
5157 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005158 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005159 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5160 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5161 ") is not 1.",
5162 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005163 }
5164 }
5165
Jeff Bolz9af91c52018-09-01 21:53:57 -05005166 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005167 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005168 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5169 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5170 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5171 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005172 }
5173
5174 return skip;
5175}
5176
Jeff Bolz5c801d12019-10-09 10:38:45 -05005177bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5178 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5179 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005180 bool skip = false;
5181
Dave Houlton142c4cb2018-10-17 15:04:41 -06005182 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005183 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5184 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5185 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005186 }
5187
5188 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005189 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005190 }
5191
5192 return skip;
5193}
5194
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005195bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005196 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005197 bool skip = false;
5198
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005199 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005200 skip |= LogError(
5201 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005202 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5203 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005204 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005205 }
5206
5207 return skip;
5208}
5209
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005210bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5211 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005212 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005213 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005214 static const int condition_multiples = 0b0011;
5215 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005216 skip |= LogError(
5217 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005218 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005219 }
Lockee1c22882019-06-10 16:02:54 -06005220 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005221 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5222 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5223 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5224 stride);
Lockee1c22882019-06-10 16:02:54 -06005225 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005226 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005227 skip |= LogError(
5228 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005229 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5230 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005231 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005232 if (drawCount > device_limits.maxDrawIndirectCount) {
5233 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005234 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5235 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005236 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005237 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005238 return skip;
5239}
5240
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005241bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5242 VkDeviceSize offset, VkBuffer countBuffer,
5243 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005244 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005245 bool skip = false;
5246
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005247 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005248 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5249 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5250 "), is not a multiple of 4.",
5251 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005252 }
5253
5254 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005255 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5256 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5257 "), is not a multiple of 4.",
5258 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005259 }
5260
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005261 return skip;
5262}
5263
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005264bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005265 const VkAllocationCallbacks *pAllocator,
5266 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005267 bool skip = false;
5268
5269 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5270 if (pCreateInfo != nullptr) {
5271 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5272 // VkQueryPipelineStatisticFlagBits values
5273 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5274 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005275 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5276 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5277 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5278 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005279 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005280 if (pCreateInfo->queryCount == 0) {
5281 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5282 "vkCreateQueryPool(): queryCount must be greater than zero.");
5283 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005284 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005285 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005286}
5287
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005288bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5289 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005290 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005291 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5292 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005293}
5294
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005295void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005296 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5297 VkResult result) {
5298 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005299 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005300}
5301
Mike Schuchardt2df08912020-12-15 16:28:09 -08005302void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005303 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5304 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005305 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005306 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005307 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005308}
5309
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005310void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5311 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005312 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005313 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005314 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005315}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005316
Tony-LunarG3c287f62020-12-17 12:39:49 -07005317void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005318 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005319 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005320 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005321 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005322 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005323 }
5324 }
5325}
5326
5327void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005328 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005329 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005330 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5331 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5332 }
5333}
5334
5335void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005336 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005337 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005338 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5339 if (item->second == commandPool) {
5340 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005341 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005342 ++item;
5343 }
5344 }
5345}
5346
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005347bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005348 const VkAllocationCallbacks *pAllocator,
5349 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005350 bool skip = false;
5351
5352 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005353 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005354 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005355 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5356 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005357 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005358
5359 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005360 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005361 if (flags_info) {
5362 flags = flags_info->flags;
5363 }
5364
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005365 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005366 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005367 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005368 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5369 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005370 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005371 }
5372
5373#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005374 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005375#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005376 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5377 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005378#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005379 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005380#endif
5381
5382 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005383 skip |= LogError(
5384 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005385 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5386 }
5387 if (
5388#ifdef VK_USE_PLATFORM_WIN32_KHR
5389 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5390#endif
5391 (import_memory_fd && import_memory_fd->handleType) ||
5392#ifdef VK_USE_PLATFORM_ANDROID_KHR
5393 (import_memory_ahb && import_memory_ahb->buffer) ||
5394#endif
5395 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005396 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5397 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005398 }
5399 }
5400
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005401 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5402 if (export_memory) {
5403 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5404 if (export_memory_nv) {
5405 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5406 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5407 "VkExportMemoryAllocateInfoNV");
5408 }
5409#ifdef VK_USE_PLATFORM_WIN32_KHR
5410 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5411 if (export_memory_win32_nv) {
5412 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5413 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5414 "VkExportMemoryWin32HandleInfoNV");
5415 }
5416#endif
5417 }
5418
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005419 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005420 VkBool32 capture_replay = false;
5421 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005422 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005423 if (vulkan_12_features) {
5424 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5425 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5426 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005427 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005428 if (bda_features) {
5429 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5430 buffer_device_address = bda_features->bufferDeviceAddress;
5431 }
5432 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005433 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005434 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005435 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005436 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005437 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005438 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005439 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005440 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005441 }
5442 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005443 }
5444 return skip;
5445}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005446
Jason Macnak192fa0e2019-07-26 15:07:16 -07005447bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005448 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005449 bool skip = false;
5450
5451 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5452 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5453 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005454 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005455 } else {
5456 uint32_t vertex_component_size = 0;
5457 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5458 vertex_component_size = 4;
5459 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5460 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5461 vertex_component_size = 2;
5462 }
5463 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005464 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005465 }
5466 }
5467
5468 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5469 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005470 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005471 } else {
5472 uint32_t index_element_size = 0;
5473 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5474 index_element_size = 4;
5475 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5476 index_element_size = 2;
5477 }
5478 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005479 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005480 }
5481 }
5482 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5483 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005484 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005485 }
5486 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005487 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005488 }
5489 }
5490
5491 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005492 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005493 }
5494
5495 return skip;
5496}
5497
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005498bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5499 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005500 bool skip = false;
5501
5502 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005503 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005504 }
5505 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005506 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005507 }
5508
5509 return skip;
5510}
5511
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005512bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5513 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005514 bool skip = false;
5515 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005516 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005517 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005518 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005519 }
5520 return skip;
5521}
5522
5523bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005524 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005525 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005526 bool skip = false;
5527 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005528 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5529 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5530 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005531 }
5532 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005533 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5534 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5535 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005536 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005537 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5538 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5539 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5540 }
Jason Macnak5c954952019-07-09 15:46:12 -07005541 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5542 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005543 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5544 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5545 "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 -07005546 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005547 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005548 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005549 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5550 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005551 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5552 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005553 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005554 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005555 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5556 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5557 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005558 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005559 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005560 uint64_t total_triangle_count = 0;
5561 for (uint32_t i = 0; i < info.geometryCount; i++) {
5562 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005563
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005564 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005565
Jason Macnak5c954952019-07-09 15:46:12 -07005566 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5567 continue;
5568 }
5569 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5570 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005571 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005572 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5573 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5574 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005575 }
5576 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005577 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5578 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5579 for (uint32_t i = 1; i < info.geometryCount; i++) {
5580 const VkGeometryNV &geometry = info.pGeometries[i];
5581 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005582 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005583 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5584 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005585 "info.pGeometries[0].geometryType.",
5586 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005587 }
5588 }
5589 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005590 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5591 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5592 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5593 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5594 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5595 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5596 }
5597 }
5598 skip |=
5599 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005600 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005601 return skip;
5602}
5603
Ricardo Garciaa4935972019-02-21 17:43:18 +01005604bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5605 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005606 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005607 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005608 if (pCreateInfo) {
5609 if ((pCreateInfo->compactedSize != 0) &&
5610 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005611 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5612 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5613 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5614 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005615 }
Jason Macnak5c954952019-07-09 15:46:12 -07005616
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005617 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005618 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005619 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005620 return skip;
5621}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005622
Jeff Bolz5c801d12019-10-09 10:38:45 -05005623bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5624 const VkAccelerationStructureInfoNV *pInfo,
5625 VkBuffer instanceData, VkDeviceSize instanceOffset,
5626 VkBool32 update, VkAccelerationStructureNV dst,
5627 VkAccelerationStructureNV src, VkBuffer scratch,
5628 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005629 bool skip = false;
5630
5631 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005632 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005633 }
5634
5635 return skip;
5636}
5637
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005638bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5639 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5640 VkAccelerationStructureKHR *pAccelerationStructure) const {
5641 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005642 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005643 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005644 if (!acceleration_structure_features ||
5645 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5646 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5647 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5648 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005649 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005650 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5651 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005652 (acceleration_structure_features &&
5653 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005654 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005655 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5656 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5657 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5658 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005659 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005660 if (pCreateInfo->deviceAddress &&
5661 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5662 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5663 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5664 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5665 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005666 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5667 (acceleration_structure_features &&
5668 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5669 skip |= LogError(
5670 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5671 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5672 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5673 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005674 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5675 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005676 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5677 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005678 }
sourav parmar83c31b12020-05-06 12:30:54 -07005679 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005680 return skip;
5681}
5682
Jason Macnak5c954952019-07-09 15:46:12 -07005683bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5684 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005685 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005686 bool skip = false;
5687 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005688 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5689 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005690 }
5691 return skip;
5692}
5693
sourav parmarcd5fb182020-07-17 12:58:44 -07005694bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5695 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5696 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5697 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005698 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005699 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005700 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005701 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005702 }
5703 return skip;
5704}
5705
Peter Chen85366392019-05-14 15:20:11 -04005706bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5707 uint32_t createInfoCount,
5708 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5709 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005710 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005711 bool skip = false;
5712
5713 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005714 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5715 std::stringstream msg;
5716 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5717 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5718 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005719 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005720 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005721 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005722 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5723 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5724 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5725 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005726 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005727
5728 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005729 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005730 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5731 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5732 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5733 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5734 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5735 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5736 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5737 }
5738 }
5739
sourav parmarf4a78252020-04-10 13:04:21 -07005740 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5741 skip |=
5742 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5743 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5744 }
5745 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5746 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5747 skip |=
5748 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5749 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5750 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5751 }
5752 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5753 if (pCreateInfos[i].basePipelineIndex != -1) {
5754 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5755 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5756 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5757 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5758 "and pCreateInfos->basePipelineIndex is not -1.");
5759 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005760 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005761 skip |=
5762 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5763 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5764 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5765 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5766 "that element.");
5767 }
sourav parmarf4a78252020-04-10 13:04:21 -07005768 }
5769 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005770 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005771 skip |=
5772 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5773 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5774 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5775 "commands pCreateInfos parameter.");
5776 }
5777 } else {
5778 if (pCreateInfos[i].basePipelineIndex != -1) {
5779 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5780 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5781 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5782 }
5783 }
5784 }
5785 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5786 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5787 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5788 }
5789 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5790 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5791 "vkCreateRayTracingPipelinesNV: flags must not include "
5792 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5793 }
5794 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5795 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5796 "vkCreateRayTracingPipelinesNV: flags must not include "
5797 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5798 }
5799 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5800 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5801 "vkCreateRayTracingPipelinesNV: flags must not include "
5802 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5803 }
5804 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5805 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5806 "vkCreateRayTracingPipelinesNV: flags must not include "
5807 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5808 }
5809 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5810 skip |= LogError(
5811 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5812 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5813 }
5814 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5815 skip |= LogError(
5816 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5817 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5818 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005819 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5820 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5821 "vkCreateRayTracingPipelinesNV: flags must not include "
5822 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5823 }
5824 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5825 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5826 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5827 }
ziga-lunargdfffee42021-10-10 11:49:59 +02005828 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
5829 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
5830 "vkCreateRayTracingPipelinesNV: flags must not contain the "
5831 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
5832 }
Peter Chen85366392019-05-14 15:20:11 -04005833 }
5834
5835 return skip;
5836}
5837
sourav parmarcd5fb182020-07-17 12:58:44 -07005838bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5839 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5840 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005841 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005842 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005843 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5844 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5845 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005846 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005847 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005848 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5849 std::stringstream msg;
5850 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5851 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5852 &pCreateInfos[i].pStages[i]);
5853 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005854 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5855 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5856 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5857 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5858 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5859 }
5860 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5861 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5862 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5863 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5864 }
5865 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005866 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005867 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5868 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005869 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5870 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5871 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005872 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5873 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5874 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005875 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005876 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005877 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5878 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5879 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5880 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005881 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005882 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5883 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5884 }
5885 }
sourav parmarf4a78252020-04-10 13:04:21 -07005886 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005887 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5888 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005889 }
5890 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005891 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005892 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005893 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5894 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005895 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005896 }
5897 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5898 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5899 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005900 }
5901 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5902 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5903 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5904 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5905 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5906 skip |= LogError(
5907 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005908 "vkCreateRayTracingPipelinesKHR: If flags includes "
5909 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005910 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5911 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5912 "must not be VK_SHADER_UNUSED_KHR");
5913 }
5914 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5915 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5916 skip |= LogError(
5917 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005918 "vkCreateRayTracingPipelinesKHR: If flags includes "
5919 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005920 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5921 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5922 "element must not be VK_SHADER_UNUSED_KHR");
5923 }
5924 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005925 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5926 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5927 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5928 skip |= LogError(
5929 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5930 "vkCreateRayTracingPipelinesKHR: If "
5931 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5932 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5933 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5934 }
5935 }
sourav parmarf4a78252020-04-10 13:04:21 -07005936 }
5937 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5938 if (pCreateInfos[i].basePipelineIndex != -1) {
5939 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5940 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005941 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005942 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5943 "and pCreateInfos->basePipelineIndex is not -1.");
5944 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005945 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005946 skip |=
5947 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5948 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5949 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5950 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5951 "element.");
5952 }
sourav parmarf4a78252020-04-10 13:04:21 -07005953 }
5954 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005955 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005956 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005957 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005958 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
5959 ") must be a valid into the calling"
5960 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07005961 pCreateInfos[i].basePipelineIndex, createInfoCount);
5962 }
5963 } else {
5964 if (pCreateInfos[i].basePipelineIndex != -1) {
5965 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005966 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005967 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5968 }
5969 }
5970 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005971 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5972 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5973 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5974 "vkCreateRayTracingPipelinesKHR: If flags includes "
5975 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5976 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005977 }
5978 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5979 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5980 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5981 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5982 "pLibraryInfo and pLibraryInterface must be NULL.");
5983 }
5984 if (pCreateInfos[i].pLibraryInfo) {
5985 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5986 if (pCreateInfos[i].stageCount == 0) {
5987 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5988 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5989 "stageCount must not be 0.");
5990 }
5991 if (pCreateInfos[i].groupCount == 0) {
5992 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5993 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5994 "groupCount must not be 0.");
5995 }
5996 } else {
5997 if (pCreateInfos[i].pLibraryInterface == NULL) {
5998 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5999 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6000 "is greater than 0, its "
6001 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006002 }
6003 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006004 }
6005 if (pCreateInfos[i].pLibraryInterface) {
6006 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6007 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6008 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6009 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6010 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6011 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006012 }
6013 if (deferredOperation != VK_NULL_HANDLE) {
6014 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6015 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6016 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6017 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006018 }
6019 }
ziga-lunargdea76582021-09-17 14:38:08 +02006020 if (pCreateInfos[i].pDynamicState) {
6021 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6022 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6023 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6024 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6025 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6026 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6027 }
6028 }
6029 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006030 }
6031
6032 return skip;
6033}
6034
Mike Schuchardt21638df2019-03-16 10:52:02 -07006035#ifdef VK_USE_PLATFORM_WIN32_KHR
6036bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6037 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006038 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006039 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006040 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006041 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006042 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006043 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006044 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006045 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006046 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006047 skip |=
6048 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006049 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006050 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6051 skip |= validate_struct_type(
6052 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6053 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6054 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6055 if (pSurfaceInfo != NULL) {
6056 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6057 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6058 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6059
6060 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6061 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6062 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6063 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006064 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6065 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006066
6067 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6068 }
6069 return skip;
6070}
6071#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006072
6073bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6074 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006075 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006076 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6077 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006078 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006079 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6080 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6081 }
6082 return skip;
6083}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006084
6085bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006086 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006087 bool skip = false;
6088
6089 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006090 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006091 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006092 }
6093
6094 return skip;
6095}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006096
6097bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006098 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006099 bool skip = false;
6100
6101 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006102 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6103 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006104 }
6105
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006106 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006107 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006108 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6109 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006110 }
6111
6112 return skip;
6113}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006114
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006115bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6116 uint32_t bindingCount, const VkBuffer *pBuffers,
6117 const VkDeviceSize *pOffsets) const {
6118 bool skip = false;
6119 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006120 skip |=
6121 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6122 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6123 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006124 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6125 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006126 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6127 ") must be less than "
6128 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006129 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6130 }
6131
Jeff Bolz165818a2020-05-08 11:19:03 -05006132 for (uint32_t i = 0; i < bindingCount; ++i) {
6133 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006134 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006135 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006136 skip |=
6137 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6138 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006139 } else {
6140 if (pOffsets[i] != 0) {
6141 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006142 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6143 "] is not 0",
6144 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006145 }
6146 }
6147 }
6148 }
6149
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006150 return skip;
6151}
6152
Mark Lobodzinski84988402019-09-11 15:27:30 -06006153bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006154 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006155 bool skip = false;
6156 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006157 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6158 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006159 }
6160 return skip;
6161}
6162
6163bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006164 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006165 bool skip = false;
6166 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006167 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6168 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006169 }
6170 return skip;
6171}
Petr Kraus3d720392019-11-13 02:52:39 +01006172
6173bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6174 VkSemaphore semaphore, VkFence fence,
6175 uint32_t *pImageIndex) const {
6176 bool skip = false;
6177
6178 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006179 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6180 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006181 }
6182
6183 return skip;
6184}
6185
6186bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6187 uint32_t *pImageIndex) const {
6188 bool skip = false;
6189
6190 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006191 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6192 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006193 }
6194
6195 return skip;
6196}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006197
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006198bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6199 uint32_t firstBinding, uint32_t bindingCount,
6200 const VkBuffer *pBuffers,
6201 const VkDeviceSize *pOffsets,
6202 const VkDeviceSize *pSizes) const {
6203 bool skip = false;
6204
6205 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6206 for (uint32_t i = 0; i < bindingCount; ++i) {
6207 if (pOffsets[i] & 3) {
6208 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6209 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6210 }
6211 }
6212
6213 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6214 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6215 "%s: The firstBinding(%" PRIu32
6216 ") index is greater than or equal to "
6217 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6218 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6219 }
6220
6221 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6222 skip |=
6223 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6224 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6225 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6226 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6227 }
6228
6229 for (uint32_t i = 0; i < bindingCount; ++i) {
6230 // pSizes is optional and may be nullptr.
6231 if (pSizes != nullptr) {
6232 if (pSizes[i] != VK_WHOLE_SIZE &&
6233 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6234 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6235 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6236 ") is not VK_WHOLE_SIZE and is greater than "
6237 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6238 cmd_name, i, pSizes[i]);
6239 }
6240 }
6241 }
6242
6243 return skip;
6244}
6245
6246bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6247 uint32_t firstCounterBuffer,
6248 uint32_t counterBufferCount,
6249 const VkBuffer *pCounterBuffers,
6250 const VkDeviceSize *pCounterBufferOffsets) const {
6251 bool skip = false;
6252
6253 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6254 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6255 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6256 "%s: The firstCounterBuffer(%" PRIu32
6257 ") index is greater than or equal to "
6258 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6259 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6260 }
6261
6262 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6263 skip |=
6264 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6265 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6266 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6267 cmd_name, firstCounterBuffer, counterBufferCount,
6268 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6269 }
6270
6271 return skip;
6272}
6273
6274bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6275 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6276 const VkBuffer *pCounterBuffers,
6277 const VkDeviceSize *pCounterBufferOffsets) const {
6278 bool skip = false;
6279
6280 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6281 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6282 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6283 "%s: The firstCounterBuffer(%" PRIu32
6284 ") index is greater than or equal to "
6285 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6286 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6287 }
6288
6289 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6290 skip |=
6291 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6292 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6293 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6294 cmd_name, firstCounterBuffer, counterBufferCount,
6295 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6296 }
6297
6298 return skip;
6299}
6300
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006301bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6302 uint32_t firstInstance, VkBuffer counterBuffer,
6303 VkDeviceSize counterBufferOffset,
6304 uint32_t counterOffset, uint32_t vertexStride) const {
6305 bool skip = false;
6306
6307 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006308 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6309 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6310 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6311 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006312 }
6313
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006314 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006315 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006316 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006317 }
6318
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006319 return skip;
6320}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006321
6322bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6323 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6324 const VkAllocationCallbacks *pAllocator,
6325 VkSamplerYcbcrConversion *pYcbcrConversion,
6326 const char *apiName) const {
6327 bool skip = false;
6328
6329 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006330 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006331 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006332 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006333 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6334 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006335 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006336 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006337 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006338
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006339#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006340 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006341 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006342#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006343 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006344#endif
6345
sfricke-samsung1a72f942020-07-25 12:09:18 -07006346 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006347
6348 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006349 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006350 const VkComponentMapping components = pCreateInfo->components;
6351 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6352 if (FormatIsXChromaSubsampled(format) == true) {
6353 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6354 skip |=
6355 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006356 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6357 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006358 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006359 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006360
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006361 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6362 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6363 skip |= LogError(
6364 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6365 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6366 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6367 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6368 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006369
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006370 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6371 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6372 skip |=
6373 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006374 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6375 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006376 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006377 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006378
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006379 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6380 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6381 skip |=
6382 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006383 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6384 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006385 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006386 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006387
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006388 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006389 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6390 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6391 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006392 skip |=
6393 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006394 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6395 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006396 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6397 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006398 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006399 }
6400
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006401 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6402 // Checks same VU multiple ways in order to give a more useful error message
6403 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6404 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6405 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6406 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6407 skip |= LogError(
6408 device, vuid,
6409 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6410 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6411 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6412 string_VkComponentSwizzle(components.b));
6413 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006414
sfricke-samsunged028b02021-09-06 23:14:51 -07006415 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6416 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006417 // 3 = no [a]
6418 // 2 = no [b,a]
6419 // 1 = no [g,b,a]
6420 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006421 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006422
sfricke-samsunged028b02021-09-06 23:14:51 -07006423 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6424 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006425 skip |= LogError(device, vuid,
6426 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6427 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6428 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6429 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006430 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006431 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6432 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6433 skip |= LogError(device, vuid,
6434 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6435 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6436 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6437 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6438 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006439 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006440 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6441 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6442 skip |= LogError(device, vuid,
6443 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6444 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6445 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6446 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6447 string_VkComponentSwizzle(components.b));
6448 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006449 }
6450 }
6451
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006452 return skip;
6453}
6454
6455bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6456 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6457 const VkAllocationCallbacks *pAllocator,
6458 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6459 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6460 "vkCreateSamplerYcbcrConversion");
6461}
6462
6463bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6464 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6465 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6466 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6467 "vkCreateSamplerYcbcrConversionKHR");
6468}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006469
6470bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6471 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6472 bool skip = false;
6473 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6474 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6475
6476 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006477 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6478 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6479 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6480 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6481 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006482 }
6483 return skip;
6484}
sourav parmara96ab1a2020-04-25 16:28:23 -07006485
6486bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006487 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006488 bool skip = false;
6489 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6490 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6491 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6492 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006493 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006494 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6495 skip |= LogError(
6496 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6497 "vkCopyAccelerationStructureToMemoryKHR: The "
6498 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6499 }
6500 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6501 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6502 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6503 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6504 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6505 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006506 return skip;
6507}
6508
6509bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6510 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6511 bool skip = false;
6512 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6513 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6514 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6515 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6516 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006517 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6518 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006519 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006520 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006521 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006522 return skip;
6523}
6524
6525bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6526 const char *api_name) const {
6527 bool skip = false;
6528 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6529 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6530 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6531 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6532 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6533 api_name);
6534 }
6535 return skip;
6536}
6537
6538bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006539 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006540 bool skip = false;
6541 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006542 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006543 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006544 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006545 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6546 "vkCopyAccelerationStructureKHR: The "
6547 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006548 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006549 return skip;
6550}
6551
6552bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6553 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6554 bool skip = false;
6555 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6556 return skip;
6557}
6558
6559bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006560 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006561 bool skip = false;
6562 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006563 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006564 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6565 }
6566 return skip;
6567}
6568
6569bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006570 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006571 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006572 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006573 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006574 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6575 skip |= LogError(
6576 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6577 "vkCopyMemoryToAccelerationStructureKHR: The "
6578 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006579 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006580 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6581 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006582 return skip;
6583}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006584
sourav parmara96ab1a2020-04-25 16:28:23 -07006585bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6586 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6587 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006588 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006589 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6590 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006591 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006592 pInfo->src.deviceAddress);
6593 }
sourav parmar83c31b12020-05-06 12:30:54 -07006594 return skip;
6595}
6596bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6597 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6598 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6599 bool skip = false;
6600 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6601 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6602 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6603 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6604 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6605 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6606 }
6607 return skip;
6608}
6609bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6610 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6611 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6612 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006613 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006614 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6615 skip |= LogError(
6616 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6617 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6618 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6619 }
sourav parmar83c31b12020-05-06 12:30:54 -07006620 if (dataSize < accelerationStructureCount * stride) {
6621 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6622 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006623 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006624 dataSize, accelerationStructureCount, stride);
6625 }
6626 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6627 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6628 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6629 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6630 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6631 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6632 }
6633 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6634 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6635 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6636 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6637 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6638 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6639 stride);
6640 }
6641 }
6642 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6643 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6644 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6645 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6646 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6647 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6648 stride);
6649 }
6650 }
sourav parmar83c31b12020-05-06 12:30:54 -07006651 return skip;
6652}
6653bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6654 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6655 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006656 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006657 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6658 skip |= LogError(
6659 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6660 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6661 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006662 }
6663 return skip;
6664}
6665
6666bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006667 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6668 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6669 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6670 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006671 uint32_t width, uint32_t height, uint32_t depth) const {
6672 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006673 // RayGen
6674 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6675 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6676 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006677 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006678 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6679 0) {
6680 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6681 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6682 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6683 }
6684 // Callable
6685 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6686 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6687 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6688 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006689 }
6690 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6691 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6692 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006693 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6694 }
6695 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6696 0) {
6697 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6698 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6699 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006700 }
6701 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006702 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6703 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6704 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6705 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006706 }
6707 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6708 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006709 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6710 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006711 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006712 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6713 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6714 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6715 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6716 }
sourav parmar83c31b12020-05-06 12:30:54 -07006717 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006718 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6719 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6720 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6721 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006722 }
6723 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6724 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6725 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006726 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6727 }
6728 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6729 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6730 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6731 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6732 }
6733 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6734 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6735 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6736 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6737 }
6738 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6739 skip |=
6740 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6741 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6742 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006743 }
6744
sourav parmarcd5fb182020-07-17 12:58:44 -07006745 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6746 skip |=
6747 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6748 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6749 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6750 }
6751
6752 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6753 skip |=
6754 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6755 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6756 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006757 }
6758 return skip;
6759}
6760
sourav parmarcd5fb182020-07-17 12:58:44 -07006761bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6762 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6763 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6764 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006765 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006766 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006767 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6768 skip |= LogError(
6769 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6770 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6771 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006772 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006773 // RayGen
6774 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6775 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6776 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006777 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006778 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6779 0) {
6780 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6781 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6782 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6783 }
6784 // Callabe
6785 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6786 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6787 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6788 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006789 }
6790 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6791 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006792 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6793 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6794 }
6795 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6796 0) {
6797 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6798 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6799 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006800 }
6801 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006802 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6803 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6804 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6805 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006806 }
6807 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6808 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006809 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6810 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006811 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006812 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6813 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6814 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6815 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6816 }
sourav parmar83c31b12020-05-06 12:30:54 -07006817 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006818 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6819 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6820 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6821 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006822 }
6823 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6824 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006825 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6826 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6827 }
6828 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6829 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6830 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6831 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006832 }
6833
sourav parmarcd5fb182020-07-17 12:58:44 -07006834 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6835 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6836 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006837 }
6838 return skip;
6839}
6840bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6841 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6842 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6843 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6844 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6845 uint32_t width, uint32_t height, uint32_t depth) const {
6846 bool skip = false;
6847 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6848 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6849 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6850 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6851 }
6852 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6853 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6854 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6855 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6856 }
6857 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6858 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6859 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6860 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6861 }
6862
6863 // hitShader
6864 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6865 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6866 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6867 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6868 }
6869 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6870 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6871 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6872 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6873 }
6874 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6875 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6876 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6877 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6878 }
6879
6880 // missShader
6881 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6882 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6883 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6884 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6885 }
6886 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6887 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6888 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6889 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6890 }
6891 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6892 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6893 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6894 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6895 }
6896
6897 // raygenShader
6898 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6899 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6900 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006901 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6902 }
6903 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6904 skip |=
6905 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6906 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6907 }
6908 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6909 skip |=
6910 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6911 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6912 }
6913 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6914 skip |=
6915 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6916 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006917 }
6918 return skip;
6919}
6920
sourav parmar83c31b12020-05-06 12:30:54 -07006921bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006922 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6923 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006924 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006925 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6926 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006927 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6928 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006929 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006930 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6931 }
6932 return skip;
6933}
6934
Piers Daniell39842ee2020-07-10 16:42:33 -06006935bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6936 const VkViewport *pViewports) const {
6937 bool skip = false;
6938
6939 if (!physical_device_features.multiViewport) {
6940 if (viewportCount != 1) {
6941 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6942 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6943 ") is not 1.",
6944 viewportCount);
6945 }
6946 } else { // multiViewport enabled
6947 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6948 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6949 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6950 ") must "
6951 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6952 viewportCount, device_limits.maxViewports);
6953 }
6954 }
6955
6956 if (pViewports) {
6957 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6958 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6959 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6960 skip |= manual_PreCallValidateViewport(
6961 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6962 }
6963 }
6964
6965 return skip;
6966}
6967
6968bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6969 const VkRect2D *pScissors) const {
6970 bool skip = false;
6971
6972 if (!physical_device_features.multiViewport) {
6973 if (scissorCount != 1) {
6974 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6975 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6976 ") must "
6977 "be 1 when the multiViewport feature is disabled.",
6978 scissorCount);
6979 }
6980 } else { // multiViewport enabled
6981 if (scissorCount == 0) {
6982 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6983 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6984 ") must "
6985 "be great than zero.",
6986 scissorCount);
6987 } else if (scissorCount > device_limits.maxViewports) {
6988 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6989 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6990 ") must "
6991 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6992 scissorCount, device_limits.maxViewports);
6993 }
6994 }
6995
6996 if (pScissors) {
6997 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6998 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6999
7000 if (scissor.offset.x < 0) {
7001 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7002 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
7003 scissor.offset.x);
7004 }
7005
7006 if (scissor.offset.y < 0) {
7007 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7008 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
7009 scissor.offset.y);
7010 }
7011
7012 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7013 if (x_sum > INT32_MAX) {
7014 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
7015 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7016 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7017 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
7018 }
7019
7020 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7021 if (y_sum > INT32_MAX) {
7022 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
7023 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7024 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7025 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7026 }
7027 }
7028 }
7029
7030 return skip;
7031}
7032
7033bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7034 uint32_t bindingCount, const VkBuffer *pBuffers,
7035 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7036 const VkDeviceSize *pStrides) const {
7037 bool skip = false;
7038 if (firstBinding >= device_limits.maxVertexInputBindings) {
7039 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007040 "vkCmdBindVertexBuffers2EXT() firstBinding (%" PRIu32
7041 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007042 firstBinding, device_limits.maxVertexInputBindings);
7043 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7044 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007045 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7046 ") must be less than "
7047 "maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007048 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7049 }
7050
7051 for (uint32_t i = 0; i < bindingCount; ++i) {
7052 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007053 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06007054 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007055 skip |= LogError(
7056 commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
7057 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007058 } else {
7059 if (pOffsets[i] != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007060 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
7061 "vkCmdBindVertexBuffers2EXT() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
7062 "] is not 0",
7063 i, i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007064 }
7065 }
7066 }
7067 if (pStrides) {
7068 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007069 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
7070 "vkCmdBindVertexBuffers2EXT() pStrides[%" PRIu32 "] (%" PRIu64
7071 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7072 i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007073 }
7074 }
7075 }
7076
7077 return skip;
7078}
sourav parmarcd5fb182020-07-17 12:58:44 -07007079
7080bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7081 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7082 bool skip = false;
7083 for (uint32_t i = 0; i < infoCount; ++i) {
7084 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7085 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7086 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7087 }
7088 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7089 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7090 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7091 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7092 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7093 api_name);
7094 }
7095 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7096 skip |=
7097 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7098 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7099 }
7100 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7101 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7102 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7103 }
7104 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7105 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7106 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7107 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7108 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7109 api_name);
7110 }
7111 if (pInfos[i].pGeometries) {
7112 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7113 skip |= validate_ranged_enum(
7114 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7115 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7116 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7117 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007118 skip |= validate_struct_type(
7119 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7120 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7121 &(pInfos[i].pGeometries[j].geometry.triangles),
7122 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7123 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7124 skip |= validate_struct_pnext(
7125 api_name,
7126 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7127 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7128 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7129 skip |=
7130 validate_ranged_enum(api_name,
7131 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7132 ParameterName::IndexVector{i, j}),
7133 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7134 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7135 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7136 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7137 &pInfos[i].pGeometries[j].geometry.triangles,
7138 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7139 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7140 skip |= validate_ranged_enum(
7141 api_name,
7142 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7143 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7144 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7145
7146 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7147 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7148 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7149 }
7150 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7151 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7152 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7153 skip |=
7154 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7155 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7156 api_name);
7157 }
7158 }
7159 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7160 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7161 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7162 &pInfos[i].pGeometries[j].geometry.instances,
7163 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7164 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7165 skip |= validate_struct_type(
7166 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7167 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7168 &(pInfos[i].pGeometries[j].geometry.instances),
7169 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7170 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7171 skip |= validate_struct_pnext(
7172 api_name,
7173 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7174 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7175 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7176
7177 skip |= validate_bool32(api_name,
7178 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7179 ParameterName::IndexVector{i, j}),
7180 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7181 }
7182 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7183 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7184 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7185 &pInfos[i].pGeometries[j].geometry.aabbs,
7186 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7187 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7188 skip |= validate_struct_type(
7189 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7190 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7191 &(pInfos[i].pGeometries[j].geometry.aabbs),
7192 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7193 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7194 skip |= validate_struct_pnext(
7195 api_name,
7196 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7197 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7198 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7199 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7200 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7201 "(%s):stride must be less than or equal to 2^32-1", api_name);
7202 }
7203 }
7204 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7205 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7206 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7207 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7208 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7209 api_name);
7210 }
7211 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7212 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7213 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7214 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7215 "of elements of"
7216 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7217 api_name);
7218 }
7219 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7220 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7221 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7222 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7223 api_name);
7224 }
7225 }
7226 }
7227 }
7228 if (pInfos[i].ppGeometries != NULL) {
7229 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7230 skip |= validate_ranged_enum(
7231 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7232 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7233 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7234 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007235 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7236 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7237 &pInfos[i].ppGeometries[j]->geometry.triangles,
7238 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7239 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7240 skip |= validate_struct_type(
7241 api_name,
7242 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7243 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7244 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7245 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7246 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7247 skip |= validate_struct_pnext(
7248 api_name,
7249 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7250 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7251 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7252 skip |= validate_ranged_enum(api_name,
7253 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7254 ParameterName::IndexVector{i, j}),
7255 "VkFormat", AllVkFormatEnums,
7256 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7257 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7258 skip |= validate_ranged_enum(api_name,
7259 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7260 ParameterName::IndexVector{i, j}),
7261 "VkIndexType", AllVkIndexTypeEnums,
7262 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7263 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7264 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7265 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7266 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7267 }
7268 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7269 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7270 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7271 skip |=
7272 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7273 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7274 api_name);
7275 }
7276 }
7277 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7278 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7279 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7280 &pInfos[i].ppGeometries[j]->geometry.instances,
7281 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7282 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7283 skip |= validate_struct_type(
7284 api_name,
7285 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7286 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7287 &(pInfos[i].ppGeometries[j]->geometry.instances),
7288 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7289 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7290 skip |= validate_struct_pnext(
7291 api_name,
7292 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7293 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7294 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7295 skip |= validate_bool32(api_name,
7296 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7297 ParameterName::IndexVector{i, j}),
7298 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7299 }
7300 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7301 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7302 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7303 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7304 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7305 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7306 skip |= validate_struct_type(
7307 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7308 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7309 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7310 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7311 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7312 skip |= validate_struct_pnext(
7313 api_name,
7314 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7315 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7316 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7317 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7318 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7319 "(%s):stride must be less than or equal to 2^32-1", api_name);
7320 }
7321 }
7322 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7323 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7324 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7325 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7326 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7327 api_name);
7328 }
7329 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7330 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7331 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7332 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7333 "of elements of"
7334 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7335 api_name);
7336 }
7337 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7338 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7339 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7340 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7341 api_name);
7342 }
7343 }
7344 }
7345 }
7346 }
7347 return skip;
7348}
7349bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7350 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7351 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7352 bool skip = false;
7353 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7354 for (uint32_t i = 0; i < infoCount; ++i) {
7355 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7356 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7357 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7358 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7359 "scratchData.deviceAddress member must be a multiple of "
7360 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7361 }
7362 for (uint32_t k = 0; k < infoCount; ++k) {
7363 if (i == k) continue;
7364 bool found = false;
7365 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007366 skip |=
7367 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7368 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7369 ") of pInfos must "
7370 "not be "
7371 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7372 ") of pInfos.",
7373 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007374 found = true;
7375 }
7376 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007377 skip |=
7378 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7379 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7380 ") of pInfos must "
7381 "not be "
7382 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7383 ") of pInfos.",
7384 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007385 found = true;
7386 }
7387 if (found) break;
7388 }
7389 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7390 if (pInfos[i].pGeometries) {
7391 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7392 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7393 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7394 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7395 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7396 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7397 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7398 }
7399 } else {
7400 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7401 skip |=
7402 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7403 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7404 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7405 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7406 }
7407 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007408 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007409 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7410 skip |= LogError(
7411 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7412 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7413 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7414 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007415 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7416 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007417 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7418 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7419 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7420 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7421 }
7422 }
7423 } else if (pInfos[i].ppGeometries) {
7424 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7425 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7426 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7427 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7428 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7429 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7430 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7431 }
7432 } else {
7433 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7434 skip |=
7435 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7436 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7437 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7438 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7439 }
7440 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007441 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007442 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7443 skip |= LogError(
7444 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7445 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7446 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7447 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007448 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7449 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007450 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7451 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7452 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7453 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7454 }
7455 }
7456 }
7457 }
7458 }
7459 return skip;
7460}
7461
7462bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7463 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7464 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7465 const uint32_t *const *ppMaxPrimitiveCounts) const {
7466 bool skip = false;
7467 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7468 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007469 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007470 if (!ray_tracing_acceleration_structure_features ||
7471 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7472 skip |= LogError(
7473 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7474 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7475 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7476 }
7477 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007478 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7479 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7480 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7481 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7482 "scratchData.deviceAddress member must be a multiple of "
7483 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7484 }
7485 for (uint32_t k = 0; k < infoCount; ++k) {
7486 if (i == k) continue;
7487 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007488 skip |= LogError(
7489 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7490 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7491 ") "
7492 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7493 "any other element [%" PRIu32 ") of pInfos.",
7494 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007495 break;
7496 }
7497 }
7498 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7499 if (pInfos[i].pGeometries) {
7500 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7501 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7502 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7503 skip |= LogError(
7504 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7505 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7506 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7507 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7508 }
7509 } else {
7510 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7511 skip |= LogError(
7512 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7513 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7514 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7515 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7516 }
7517 }
7518 }
7519 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7520 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7521 skip |= LogError(
7522 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7523 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7524 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7525 }
7526 }
7527 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7528 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7529 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7530 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7531 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7532 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7533 }
7534 }
7535 } else if (pInfos[i].ppGeometries) {
7536 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7537 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7538 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7539 skip |= LogError(
7540 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7541 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7542 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7543 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7544 }
7545 } else {
7546 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7547 skip |= LogError(
7548 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7549 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7550 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7551 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7552 }
7553 }
7554 }
7555 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7556 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7557 skip |= LogError(
7558 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7559 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7560 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7561 }
7562 }
7563 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7564 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7565 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7566 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7567 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7568 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7569 }
7570 }
7571 }
7572 }
7573 }
7574 return skip;
7575}
7576
7577bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7578 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7579 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7580 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7581 bool skip = false;
7582 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7583 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007584 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007585 if (!ray_tracing_acceleration_structure_features ||
7586 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7587 skip |=
7588 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7589 "vkBuildAccelerationStructuresKHR: The "
7590 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7591 }
7592 for (uint32_t i = 0; i < infoCount; ++i) {
7593 for (uint32_t j = 0; j < infoCount; ++j) {
7594 if (i == j) continue;
7595 bool found = false;
7596 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007597 skip |=
7598 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7599 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
7600 ") of pInfos must "
7601 "not be "
7602 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7603 ") of pInfos.",
7604 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007605 found = true;
7606 }
7607 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007608 skip |=
7609 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7610 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
7611 ") of pInfos must "
7612 "not be "
7613 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7614 ") of pInfos.",
7615 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007616 found = true;
7617 }
7618 if (found) break;
7619 }
7620 }
7621 return skip;
7622}
7623
7624bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7625 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7626 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7627 bool skip = false;
7628 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7629 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007630 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7631 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007632 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7633 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7634 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7635 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7636 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7637 }
7638 return skip;
7639}
sfricke-samsungecafb192021-01-17 08:21:14 -08007640
7641bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7642 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7643 const VkAllocationCallbacks *pAllocator,
7644 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7645 bool skip = false;
7646 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7647 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7648 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7649 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7650 }
7651 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007652}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007653
7654bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7655 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7656 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7657 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7658 bool skip = false;
7659 const auto *vertex_input_dynamic_state_features =
7660 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7661 const auto *vertex_attribute_divisor_features =
7662 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7663
7664 // VUID-vkCmdSetVertexInputEXT-None-04790
7665 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7666 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7667 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7668 }
7669
7670 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7671 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7672 skip |=
7673 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7674 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7675 }
7676
7677 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7678 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7679 skip |= LogError(
7680 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7681 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7682 }
7683
7684 // VUID-vkCmdSetVertexInputEXT-binding-04793
7685 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7686 bool binding_found = false;
7687 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7688 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7689 binding_found = true;
7690 break;
7691 }
7692 }
7693 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007694 skip |= LogError(
7695 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7696 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007697 }
7698 }
7699
7700 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7701 if (vertexBindingDescriptionCount > 1) {
7702 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7703 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7704 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7705 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7706 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007707 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
7708 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007709 }
7710 }
7711 }
7712 }
7713
7714 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7715 if (vertexAttributeDescriptionCount > 1) {
7716 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7717 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7718 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7719 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7720 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007721 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
7722 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007723 }
7724 }
7725 }
7726 }
7727
7728 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7729 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7730 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007731 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7732 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7733 "].binding is greater than maxVertexInputBindings",
7734 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007735 }
7736
7737 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7738 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007739 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7740 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7741 "].stride is greater than maxVertexInputBindingStride",
7742 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007743 }
7744
7745 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7746 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7747 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7748 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007749 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7750 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007751 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7752 binding);
7753 }
7754
7755 if (pVertexBindingDescriptions[binding].divisor > 1) {
7756 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7757 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7758 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007759 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7760 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007761 "vertexAttributeInstanceRateDivisor is not enabled",
7762 binding);
7763 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007764 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007765 if (pVertexBindingDescriptions[binding].divisor >
7766 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007767 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
7768 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7769 "].divisor is greater than maxVertexAttribDivisor",
7770 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007771 }
7772
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007773 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007774 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007775 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
7776 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7777 "].divisor is greater than 1 but inputRate "
7778 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7779 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007780 }
7781 }
7782 }
7783 }
7784
7785 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007786 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007787 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007788 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
7789 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7790 "].location is greater than maxVertexInputAttributes",
7791 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007792 }
7793
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007794 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007795 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007796 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
7797 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7798 "].binding is greater than maxVertexInputBindings",
7799 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007800 }
7801
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007802 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007803 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007804 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
7805 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7806 "].offset is greater than maxVertexInputAttributeOffset",
7807 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007808 }
7809
7810 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7811 VkFormatProperties properties;
7812 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7813 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7814 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007815 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7816 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007817 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7818 attribute);
7819 }
7820 }
7821
7822 return skip;
7823}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007824
7825bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7826 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7827 const void *pValues) const {
7828 bool skip = false;
7829 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7830 // Check that offset + size don't exceed the max.
7831 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7832 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007833 skip |=
7834 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7835 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
7836 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007837 }
7838 if (size > max_push_constants_size - offset) {
7839 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007840 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
7841 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07007842 offset, size, max_push_constants_size);
7843 }
7844
7845 // size needs to be non-zero and a multiple of 4.
7846 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007847 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
7848 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007849 }
7850
7851 // offset needs to be a multiple of 4.
7852 if ((offset & 0x3) != 0) {
7853 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007854 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007855 }
7856 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007857}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007858
7859bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7860 uint32_t srcCacheCount,
7861 const VkPipelineCache *pSrcCaches) const {
7862 bool skip = false;
7863 if (pSrcCaches) {
7864 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7865 if (pSrcCaches[index0] == dstCache) {
7866 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7867 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7868 report_data->FormatHandle(dstCache).c_str());
7869 break;
7870 }
7871 }
7872 }
7873 return skip;
7874}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007875
7876bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
7877 VkImageLayout imageLayout, const VkClearColorValue *pColor,
7878 uint32_t rangeCount,
7879 const VkImageSubresourceRange *pRanges) const {
7880 bool skip = false;
7881 if (!pColor) {
7882 skip |=
7883 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
7884 }
7885 return skip;
7886}
7887
7888bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
7889 const VkRenderPassBeginInfo *const rp_begin) const {
7890 bool skip = false;
7891 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
7892 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
7893 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02007894 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007895 func_name, rp_begin->clearValueCount);
7896 }
7897 return skip;
7898}
7899
7900bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7901 VkSubpassContents) const {
7902 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
7903 return skip;
7904}
7905
7906bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
7907 const VkRenderPassBeginInfo *pRenderPassBegin,
7908 const VkSubpassBeginInfo *) const {
7909 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
7910 return skip;
7911}
7912
7913bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7914 const VkSubpassBeginInfo *) const {
7915 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
7916 return skip;
7917}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02007918
7919bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
7920 uint32_t firstDiscardRectangle,
7921 uint32_t discardRectangleCount,
7922 const VkRect2D *pDiscardRectangles) const {
7923 bool skip = false;
7924
7925 if (pDiscardRectangles) {
7926 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
7927 const int64_t x_sum =
7928 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
7929 if (x_sum > std::numeric_limits<int32_t>::max()) {
7930 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
7931 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7932 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7933 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
7934 }
7935
7936 const int64_t y_sum =
7937 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
7938 if (y_sum > std::numeric_limits<int32_t>::max()) {
7939 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
7940 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7941 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7942 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
7943 }
7944 }
7945 }
7946
7947 return skip;
7948}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02007949
7950bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
7951 uint32_t queryCount, size_t dataSize, void *pData,
7952 VkDeviceSize stride, VkQueryResultFlags flags) const {
7953 bool skip = false;
7954
7955 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
7956 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
7957 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
7958 }
7959
7960 return skip;
7961}
ziga-lunargcf340c42021-08-19 00:13:38 +02007962
7963bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
7964 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
7965 bool skip = false;
7966
7967 if ((pConditionalRenderingBegin->offset & 3) != 0) {
7968 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
7969 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
7970 ") is not a multiple of 4.",
7971 pConditionalRenderingBegin->offset);
7972 }
7973
7974 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06007975}