blob: 7e8b6374847f23982e5077206576c03868609985 [file] [log] [blame]
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
sfricke-samsung2e827212021-09-28 07:52:08 -070027#include "core_validation_error_enums.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010028
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070029static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060030
John Zulauf71968502017-10-26 13:51:15 -060031template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070032inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060033 // Using only < for generality and || for early abort
34 return !((value < min) || (max < value));
35}
36
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070037read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); }
38write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); }
39
Jeremy Gebbencbf22862021-03-03 12:01:22 -070040static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070041static ReadWriteLock secondary_cb_map_mutex;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -070042static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); }
43static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070044
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070045bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050046 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 bool skip = false;
48
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070049 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050
51 if (result == VK_STRING_ERROR_NONE) {
52 return skip;
53 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070054 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070055 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060056 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070057 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
58 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060059 }
60 return skip;
61}
62
Jeff Bolz46c0ea02019-10-09 13:06:29 -050063bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060064 bool skip = false;
65 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
66 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080067 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
68 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070069 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
70 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
71 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060072 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070073 skip |= LogWarning(instance, kVUIDUndefined,
74 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
75 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
76 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060077 }
78 }
79 return skip;
80}
81
Jeff Bolz46c0ea02019-10-09 13:06:29 -050082bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060083 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060084 // Create and use a local instance extension object, as an actual instance has not been created yet
85 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
86 InstanceExtensions local_instance_extensions;
87 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
88
John Zulauf620755c2018-04-16 11:00:43 -060089 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060090 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
91 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060092 }
93
94 return skip;
95}
96
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060097bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -070098 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060099 // Struct is legal IF it's supported
100 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
101 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
102 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
103 if (enum_iter != dev_exts_enumerated->second.cend()) {
104 return true;
105 }
106 }
107 return false;
108}
109
Tony-LunarG866843d2020-05-13 11:22:42 -0600110bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
111 const VkValidationFeaturesEXT *validation_features) const {
112 bool skip = false;
113 bool debug_printf = false;
114 bool gpu_assisted = false;
115 bool reserve_slot = false;
116 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
117 switch (validation_features->pEnabledValidationFeatures[i]) {
118 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
119 gpu_assisted = true;
120 break;
121
122 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
123 debug_printf = true;
124 break;
125
126 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
127 reserve_slot = true;
128 break;
129
130 default:
131 break;
132 }
133 }
134 if (reserve_slot && !gpu_assisted) {
135 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
136 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
137 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
138 }
139 if (gpu_assisted && debug_printf) {
140 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
141 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
142 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
143 }
144
145 return skip;
146}
147
John Zulauf620755c2018-04-16 11:00:43 -0600148template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700149ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
150 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600151 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700152 ExtEnabled state =
153 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600154 return state;
155}
156
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700157bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500158 const VkAllocationCallbacks *pAllocator,
159 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700160 bool skip = false;
161 // Note: From the spec--
162 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
163 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
164 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700165 ? pCreateInfo->pApplicationInfo->apiVersion
166 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700167 skip |= validate_api_version(local_api_version, api_version);
168 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700169 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600170 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
171
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700172 return skip;
173}
174
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700175void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700176 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
177 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700178 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
179 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700180 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700181 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700182}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600183
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700184void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
185 // Assume phys_devices is valid
186 assert(phys_devices);
187 for (int i = 0; i < count; ++i) {
188 const auto &phys_device = phys_devices[i];
189 if (0 == physical_device_properties_map.count(phys_device)) {
190 auto phys_dev_props = new VkPhysicalDeviceProperties;
191 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
192 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600193
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700194 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
195 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700196 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700197 std::vector<VkExtensionProperties> ext_props{};
198 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
199 ext_props.resize(ext_count);
200 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
201 for (uint32_t j = 0; j < ext_count; j++) {
202 dev_exts_enumerated.insert(ext_props[j].extensionName);
203 }
204 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600205 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700206 }
207}
208
209void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
210 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
211 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
212 return;
213 }
214
215 if (pPhysicalDeviceCount && pPhysicalDevices) {
216 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
217 }
218}
219
220void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
221 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
222 VkResult result) {
223 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
224 return;
225 }
226
227 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
228 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
229 const auto &group = pPhysicalDeviceGroupProperties[i];
230 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
231 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600232 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700233}
234
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600235void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
236 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
237 delete (it->second);
238 it = physical_device_properties_map.erase(it);
239 }
240};
241
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700242void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700243 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700244 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700245 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700246 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
247 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700249 // Parmeter validation also uses extension data
250 stateless_validation->device_extensions = this->device_extensions;
251
252 VkPhysicalDeviceProperties device_properties = {};
253 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600254 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700255 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
256
sfricke-samsung45996a42021-09-16 13:45:27 -0700257 if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700258 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700259 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
260 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600261 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700262 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
263 }
264
sfricke-samsung45996a42021-09-16 13:45:27 -0700265 if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700266 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700267 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
268 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600269 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700270 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
271 }
272
sfricke-samsung45996a42021-09-16 13:45:27 -0700273 if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) {
Jason Macnak5c954952019-07-09 15:46:12 -0700274 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700275 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
276 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700277 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500278 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
279 }
280
sfricke-samsung45996a42021-09-16 13:45:27 -0700281 if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500282 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700283 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
284 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500285 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
286 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700287 }
288
sfricke-samsung45996a42021-09-16 13:45:27 -0700289 if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) {
sourav parmarcd5fb182020-07-17 12:58:44 -0700290 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700291 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
292 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700293 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
294 phys_dev_ext_props.acc_structure_props = acc_structure_props;
295 }
296
sfricke-samsung45996a42021-09-16 13:45:27 -0700297 if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) {
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700298 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700299 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
300 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700301 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
302 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
303 }
304
sfricke-samsung45996a42021-09-16 13:45:27 -0700305 if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) {
Piers Daniellcb6d8032021-04-19 18:51:26 -0600306 // Get the needed vertex attribute divisor limits
307 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
308 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
309 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
310 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
311 }
312
sfricke-samsung45996a42021-09-16 13:45:27 -0700313 if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) {
ziga-lunarga283d022021-08-04 18:35:23 +0200314 // Get the needed vertex attribute divisor limits
315 auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>();
316 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props);
317 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
318 phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props;
319 }
320
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800321 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
322
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700323 // Save app-enabled features in this device's validation object
324 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700325 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200326 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
327 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
328 if (features2) {
329 tmp_features2_state.features = features2->features;
330 } else if (pCreateInfo->pEnabledFeatures) {
331 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700332 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200333 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700334 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200335 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700336 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200337 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700338}
339
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700340bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500341 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600342 bool skip = false;
343
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200344 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
345 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
346 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600347 }
348
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700349 // If this device supports VK_KHR_portability_subset, it must be enabled
350 const std::string portability_extension_name("VK_KHR_portability_subset");
351 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
352 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
353 bool portability_requested = false;
354
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200355 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
356 skip |=
357 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
358 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
359 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
360 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700361 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
362 portability_requested = true;
363 }
364 }
365
366 if (portability_supported && !portability_requested) {
367 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
368 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
369 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600370 }
371
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200372 {
Mike Schuchardt7cc57842021-09-15 10:49:59 -0700373 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME));
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700374 bool negative_viewport =
375 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200376 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700377 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
378 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
379 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200380 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600381 }
382
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600383 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200384 bool khr_bda =
385 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
386 bool ext_bda =
387 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600388 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700389 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
390 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
391 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600392 }
393 }
394
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600395 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
396 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700397 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600398 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800399 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700400 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800401 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700402 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600403 }
404 }
405
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700406 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500407 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700408 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500409 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
410 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
411 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
412 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700413 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700414 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
415 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
416 skip |= LogError(
417 device,
418 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
419 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
420 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700421 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700422 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -0700423 if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) {
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600424 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
425 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
426 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600427 }
428
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700429 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700430 if (vulkan_11_features) {
431 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
432 while (current) {
433 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
434 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
435 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
436 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
437 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
438 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700439 skip |= LogError(
440 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700441 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
442 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
443 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
444 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
445 break;
446 }
447 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
448 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800449
450 // Check features are enabled if matching extension is passed in as well
451 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
452 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
453 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
454 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
455 skip |= LogError(
456 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
457 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
458 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
459 }
460 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700461 }
462
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700463 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700464 if (vulkan_12_features) {
465 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
466 while (current) {
467 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
469 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
470 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
471 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
472 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
473 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
474 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
475 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
476 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
477 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
478 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
479 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700480 skip |= LogError(
481 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700482 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
483 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
484 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
485 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
486 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
487 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
488 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
489 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
490 break;
491 }
492 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
493 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700494 // Check features are enabled if matching extension is passed in as well
495 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
496 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
497 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
498 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
499 skip |= LogError(
500 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
501 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
502 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
503 }
504 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
505 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
506 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
507 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
508 "is not VK_TRUE.",
509 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
510 }
511 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
512 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
513 skip |= LogError(
514 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
515 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
516 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
517 }
518 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
519 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
520 skip |= LogError(
521 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
522 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
523 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
524 }
525 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
526 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
527 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
528 skip |=
529 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
530 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
531 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
532 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
533 }
534 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200535 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
536 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
537 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
538 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
539 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
540 }
541 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700542 }
543
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600544 // Validate pCreateInfo->pQueueCreateInfos
545 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600546
547 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700548 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
549 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600550 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700551 skip |=
552 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
553 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
554 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
555 "index value.",
556 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600557 }
558
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700559 if (queue_create_info.pQueuePriorities != nullptr) {
560 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
561 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600562 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700563 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
564 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
565 "] (=%f) is not between 0 and 1 (inclusive).",
566 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600567 }
568 }
569 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700570
571 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700572 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700573 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700574 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700575 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700576 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700577 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700578 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700579 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700580 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700581 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
582 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
583 "protectedMemory feature being set as well.");
584 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600585 }
586 }
587
sfricke-samsung30a57412020-05-15 21:14:54 -0700588 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700589 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700590 VkBool32 variable_pointers = VK_FALSE;
591 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700592 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700593 variable_pointers = vulkan_11_features->variablePointers;
594 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700595 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700596 variable_pointers = variable_pointers_features->variablePointers;
597 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700598 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700599 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700600 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
601 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
602 }
603
sfricke-samsungfd76c342020-05-29 23:13:43 -0700604 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700605 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700606 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700607 VkBool32 multiview_geometry_shader = VK_FALSE;
608 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700609 if (vulkan_11_features) {
610 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700611 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
612 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700613 } else if (multiview_features) {
614 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700615 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
616 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700617 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700618 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700619 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
620 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
621 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700622 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700623 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
624 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
625 }
626
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600627 return skip;
628}
629
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500630bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700631 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700632 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
633 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
634 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600635 }
636
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700637 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600638}
639
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700640bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500641 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100642 bool skip = false;
643
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600644 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700645 skip |=
646 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600647
648 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
649 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
650 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
651 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700652 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
653 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
654 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600655 }
656
657 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
658 // queueFamilyIndexCount uint32_t values
659 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700660 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
661 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
662 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
663 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600664 }
665 }
666
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700667 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
668 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
669 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
670 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
671 }
672
673 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
674 skip |=
675 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
676 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
677 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
678 }
679
680 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
681 skip |=
682 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
683 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
684 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
685 }
686
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600687 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
688 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
689 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
690 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700691 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
692 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
693 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600694 }
695 }
696
697 return skip;
698}
699
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700700bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500701 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600702 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703
704 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800705 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700706 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600707 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
708 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
709 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
710 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
712 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
713 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714 }
715
716 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
717 // queueFamilyIndexCount uint32_t values
718 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700719 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
720 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
721 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
722 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600723 }
724 }
725
Dave Houlton413a6782018-05-22 13:01:54 -0600726 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700727 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600728 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700729 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600730 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700731 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600732
Dave Houlton413a6782018-05-22 13:01:54 -0600733 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700734 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600735 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700736 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600737
Dave Houlton130c0212018-01-29 13:39:56 -0700738 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700739 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
740 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700741 skip |= LogError(
742 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600743 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
744 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700745 }
746
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600747 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100748 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
749 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
751 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
752 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 }
754
755 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700756 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100757 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700758 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
759 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
760 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
761 ") are not equal.",
762 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100763 }
764
765 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
767 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
768 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
769 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100770 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600771 }
772
773 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700774 skip |= LogError(
775 device, "VUID-VkImageCreateInfo-imageType-00957",
776 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600777 }
778 }
779
Dave Houlton130c0212018-01-29 13:39:56 -0700780 // 3D image may have only 1 layer
781 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700782 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
783 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700784 }
785
Dave Houlton130c0212018-01-29 13:39:56 -0700786 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
787 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
788 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
789 // At least one of the legal attachment bits must be set
790 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700791 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
792 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700793 }
794 // No flags other than the legal attachment bits may be set
795 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
796 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
798 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700799 }
800 }
801
Jeff Bolzef40fec2018-09-01 22:04:34 -0500802 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700803 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500804 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700805 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700806 ? static_cast<uint32_t>(ceil(log2(max_dim)))
807 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
808 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600809 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700810 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
811 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
812 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600813 }
814
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700815 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700816 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
817 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
818 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600819 }
820
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700821 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700822 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
823 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
824 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100825 }
826
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700827 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700828 skip |= LogError(
829 device, "VUID-VkImageCreateInfo-flags-01924",
830 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
831 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
832 }
833
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600834 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
835 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700836 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
837 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700838 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
839 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
840 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600841 }
842
843 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700844 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600845 // Linear tiling is unsupported
846 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700847 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700848 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
849 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600850 }
851
852 // Sparse 1D image isn't valid
853 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700854 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
855 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600856 }
857
858 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700859 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700860 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
861 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
862 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600863 }
864
865 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700866 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700867 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
868 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
869 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600870 }
871
872 // Multi-sample 2D image when device doesn't support it
873 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700874 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600875 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700876 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
877 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
878 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700879 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600880 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700881 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
882 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
883 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700884 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600885 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700886 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
887 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
888 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700889 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600890 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700891 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
892 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
893 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600894 }
895 }
896 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500897
Jeff Bolz9af91c52018-09-01 21:53:57 -0500898 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
899 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700900 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
901 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
902 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500903 }
904 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700905 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
906 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
907 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500908 }
909 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700910 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
911 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
912 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500913 }
914 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500915
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700916 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600917 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700918 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
919 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
920 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500921 }
922
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700923 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700924 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
925 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800926 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
927 "depth/stencil format.",
928 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500929 }
930
Dave Houlton142c4cb2018-10-17 15:04:41 -0600931 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700932 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
933 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
934 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
935 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500936 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600937 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700938 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
939 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
940 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
941 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500942 }
943 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500944
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700945 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800946 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700947 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
948 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800949 "format (%s) must be a depth or depth/stencil format.",
950 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700951 }
952
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700953 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500954 if (image_stencil_struct != nullptr) {
955 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
956 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
957 // No flags other than the legal attachment bits may be set
958 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
959 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700960 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
961 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
962 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
963 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500964 }
965 }
966
sfricke-samsung61a57c02021-01-10 21:35:12 -0800967 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500968 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
969 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800970 skip |= LogError(
971 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 (%u) exceeds device "
974 "maxFramebufferWidth (%u)",
975 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500976 }
977
978 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800979 skip |= LogError(
980 device, "VUID-VkImageCreateInfo-format-02537",
981 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
982 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
983 "maxFramebufferHeight (%u)",
984 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500985 }
986 }
987
988 if (!physical_device_features.shaderStorageImageMultisample &&
989 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
990 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
991 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700992 LogError(device, "VUID-VkImageCreateInfo-format-02538",
993 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
994 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
995 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500996 }
997
998 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
999 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001000 skip |= LogError(
1001 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001002 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1003 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1004 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1005 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1006 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001007 skip |= LogError(
1008 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001009 "vkCreateImage(): Depth-stencil image in which usage does not include "
1010 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1011 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1012 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1013 }
1014
1015 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1016 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001017 skip |= LogError(
1018 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001019 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1020 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1021 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1022 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1023 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001024 skip |= LogError(
1025 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001026 "vkCreateImage(): Depth-stencil image in which usage does not include "
1027 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1028 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1029 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1030 }
1031 }
1032 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001033
1034 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1035 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1036 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1037 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1038 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1039 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001040
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001041 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001042 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001043 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1044 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001045 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1046 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1047 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1048 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1049 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1050 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1051 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001052 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001053 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1054 } else if (drm_format_mod_list != nullptr) {
1055 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1056 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1057 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001058 }
1059 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1060 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1061 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1062 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1063 "in the pNext chain");
1064 }
1065 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001066
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001067 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001068 bool image_create_maybe_linear = false;
1069 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1070 image_create_maybe_linear = true;
1071 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1072 image_create_maybe_linear = false;
1073 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1074 image_create_maybe_linear =
1075 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001076 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001077 }
1078
1079 // If multi-sample, validate type, usage, tiling and mip levels.
1080 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001081 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001082 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1083 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1084 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1085 }
1086
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001087 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001088 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1089 image_create_maybe_linear)) {
1090 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1091 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1092 }
1093
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001094 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1095 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1096 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1097 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1098 "imageType must be VK_IMAGE_TYPE_2D.");
1099 }
1100 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1101 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1102 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1103 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1104 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001105 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001106 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001107 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1108 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1109 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1110 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1111 }
1112 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1113 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1114 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1115 "imageType must be VK_IMAGE_TYPE_2D.");
1116 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001117 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001118 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1119 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1120 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1121 }
1122 if (pCreateInfo->mipLevels != 1) {
1123 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1124 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1125 pCreateInfo->mipLevels);
1126 }
1127 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001128
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001129 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001130 if (swapchain_create_info != nullptr) {
1131 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1132 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1133 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1134 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1135 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1136 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1137
1138 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1139 // also implicitly forces the check above that extent.depth is 1
1140 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1141 string_VkImageType(pCreateInfo->imageType));
1142 }
1143 if (pCreateInfo->mipLevels != 1) {
1144 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1145 pCreateInfo->mipLevels);
1146 }
1147 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1148 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1149 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1150 }
1151 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1152 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1153 base_message, string_VkImageTiling(pCreateInfo->tiling));
1154 }
1155 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1156 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1157 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1158 }
1159 const VkImageCreateFlags valid_flags =
1160 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001161 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001162 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001163 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001164 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001165 }
1166 }
1167 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001168
1169 // If Chroma subsampled format ( _420_ or _422_ )
1170 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1171 skip |=
1172 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1173 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1174 ") must be a multiple of 2.",
1175 string_VkFormat(image_format), pCreateInfo->extent.width);
1176 }
1177 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1178 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1179 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1180 ") must be a multiple of 2.",
1181 string_VkFormat(image_format), pCreateInfo->extent.height);
1182 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001183
1184 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1185 if (format_list_info) {
1186 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1187 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1188 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1189 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1190 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1191 viewFormatCount);
1192 }
1193 // Check if viewFormatCount is not zero that it is all compatible
1194 for (uint32_t i = 0; i < viewFormatCount; i++) {
1195 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1196 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1197 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1198 "VkImageCreateInfo::format (%s) are not compatible.",
Esther O'Keefed37c24b2021-09-27 12:45:40 +10001199 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001200 }
1201 }
1202 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001203 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001204
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001205 return skip;
1206}
1207
Jeff Bolz99e3f632020-03-24 22:59:22 -05001208bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1209 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1210 bool skip = false;
1211
1212 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001213 // Validate feature set if using CUBE_ARRAY
1214 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1215 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1216 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1217 "enabling the imageCubeArray feature.");
1218 }
1219
Jeff Bolz99e3f632020-03-24 22:59:22 -05001220 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1221 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1222 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001223 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001224 pCreateInfo->subresourceRange.layerCount);
1225 }
1226 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001227 skip |= LogError(
1228 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1229 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1230 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001231 }
1232 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001233
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001234 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001235 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001236 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1237 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1238 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1239 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1240 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1241 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1242 }
1243 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1244 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1245 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1246 "not an ASTC format.",
1247 string_VkFormat(pCreateInfo->format));
1248 }
1249 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001250
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001251 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001252 if (ycbcr_conversion != nullptr) {
1253 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1254 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1255 skip |= LogError(
1256 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1257 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1258 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1259 "r swizzle = %s\n"
1260 "g swizzle = %s\n"
1261 "b swizzle = %s\n"
1262 "a swizzle = %s\n",
1263 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1264 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1265 }
1266 }
1267 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001268 }
1269 return skip;
1270}
1271
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001272bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001273 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001274 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001275
1276 // Note: for numerical correctness
1277 // - float comparisons should expect NaN (comparison always false).
1278 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1279
1280 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001281 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001282 if (v1_f <= 0.0f) return true;
1283
1284 float intpart;
1285 const float fract = modff(v1_f, &intpart);
1286
1287 assert(std::numeric_limits<float>::radix == 2);
1288 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1289 if (intpart >= u32_max_plus1) return false;
1290
1291 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001292 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001293 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001294 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001295 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001296 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001297 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001298 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001299 };
1300
1301 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1302 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1303 return (v1_f <= v2_f);
1304 };
1305
1306 // width
1307 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001308 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001309
1310 if (!(viewport.width > 0.0f)) {
1311 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001312 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1313 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001314 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1315 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001316 skip |= LogError(object, "VUID-VkViewport-width-01771",
1317 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1318 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001319 }
1320
1321 // height
1322 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001323 const bool negative_height_enabled =
1324 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001325 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001326
1327 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1328 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001329 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1330 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001331 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1332 height_healthy = false;
1333
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001334 skip |= LogError(object, "VUID-VkViewport-height-01773",
1335 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1336 ").",
1337 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001338 }
1339
1340 // x
1341 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001342 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001343 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001344 skip |= LogError(object, "VUID-VkViewport-x-01774",
1345 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1346 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001347 }
1348
1349 // x + width
1350 if (x_healthy && width_healthy) {
1351 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001352 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001353 skip |= LogError(
1354 object, "VUID-VkViewport-x-01232",
1355 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1356 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1357 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001358 }
1359 }
1360
1361 // y
1362 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001363 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001364 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001365 skip |= LogError(object, "VUID-VkViewport-y-01775",
1366 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1367 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001368 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
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-01776",
1371 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1372 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001373 }
1374
1375 // y + height
1376 if (y_healthy && height_healthy) {
1377 const float boundary = viewport.y + viewport.height;
1378
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001379 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001380 skip |= LogError(object, "VUID-VkViewport-y-01233",
1381 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1382 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1383 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001384 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001385 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001386 LogError(object, "VUID-VkViewport-y-01777",
1387 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1388 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1389 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001390 }
1391 }
1392
sfricke-samsungfd06d422021-01-22 02:17:21 -08001393 // 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 -07001394 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001395 // minDepth
1396 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001397 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001398 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001399 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1400 "[0.0, 1.0] range.",
1401 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001402 }
1403
1404 // maxDepth
1405 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001406 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001407 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001408 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1409 "[0.0, 1.0] range.",
1410 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001411 }
1412 }
1413
1414 return skip;
1415}
1416
Dave Houlton142c4cb2018-10-17 15:04:41 -06001417struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001418 VkShadingRatePaletteEntryNV shadingRate;
1419 uint32_t width;
1420 uint32_t height;
1421};
1422
1423// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001424static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001425 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1426 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1427 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1428 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1429 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1430 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001431};
1432
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001433bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001434 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001435
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001436 SampleOrderInfo *sample_order_info;
1437 uint32_t info_idx = 0;
1438 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1439 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1440 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001441 break;
1442 }
1443 }
1444
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001445 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001446 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1447 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1448 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001449 return skip;
1450 }
1451
Dave Houlton142c4cb2018-10-17 15:04:41 -06001452 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001453 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001454 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1455 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1456 ") must "
1457 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1458 "is set in framebufferNoAttachmentsSampleCounts.",
1459 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001460 }
1461
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001462 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001463 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1464 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1465 ") must "
1466 "be equal to the product of sampleCount (=%" PRIu32
1467 "), the fragment width for shadingRate "
1468 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001469 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001470 }
1471
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001472 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001473 skip |= LogError(
1474 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001475 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1476 ") must "
1477 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001478 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001479 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001480
1481 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001482 // the first width*height*sampleCount bits to all be set. Note: There is no
1483 // guarantee that 64 bits is enough, but practically it's unlikely for an
1484 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001485 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001486 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001487 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001488 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1489 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001490 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1491 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001492 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001493 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001494 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1495 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001496 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001497 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001498 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1499 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001500 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001501 uint32_t idx =
1502 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1503 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001504 }
1505
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001506 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1507 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001508 skip |= LogError(
1509 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001510 "The array pSampleLocations must contain exactly one entry for "
1511 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001512 }
1513
1514 return skip;
1515}
1516
sfricke-samsung51303fb2021-05-09 19:09:13 -07001517bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1518 const VkAllocationCallbacks *pAllocator,
1519 VkPipelineLayout *pPipelineLayout) const {
1520 bool skip = false;
1521 // Validate layout count against device physical limit
1522 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1523 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
1524 "vkCreatePipelineLayout(): setLayoutCount (%d) exceeds physical device maxBoundDescriptorSets limit (%d).",
1525 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1526 }
1527
1528 // Validate Push Constant ranges
1529 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1530 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1531 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1532 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1533 // Check that offset + size don't exceed the max.
1534 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1535 if (offset >= max_push_constants_size) {
1536 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
1537 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) that exceeds this "
1538 "device's maxPushConstantSize of %u.",
1539 i, offset, max_push_constants_size);
1540 }
1541 if (size > max_push_constants_size - offset) {
1542 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
1543 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u] offset (%u) and size (%u) "
1544 "together exceeds this device's maxPushConstantSize of %u.",
1545 i, offset, size, max_push_constants_size);
1546 }
1547
1548 // size needs to be non-zero and a multiple of 4.
1549 if (size == 0) {
1550 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
1551 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not greater than zero.",
1552 i, size);
1553 }
1554 if (size & 0x3) {
1555 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
1556 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not a multiple of 4.", i,
1557 size);
1558 }
1559
1560 // offset needs to be a multiple of 4.
1561 if ((offset & 0x3) != 0) {
1562 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
1563 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) is not a multiple of 4.",
1564 i, offset);
1565 }
1566 }
1567
1568 // 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.
1569 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1570 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1571 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
1572 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1573 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %d and %d.", i, j);
1574 }
1575 }
1576 }
1577 return skip;
1578}
1579
ziga-lunargc6341372021-07-28 12:57:42 +02001580bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1581 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1582 bool skip = false;
1583
1584 const auto *required_subgroup_size_features =
1585 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1586
1587 if (required_subgroup_size_features) {
1588 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1589 skip |= LogError(
1590 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1591 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1592 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1593 func_name, msg, pCreateInfo->flags);
1594 }
1595 }
1596
1597 return skip;
1598}
1599
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001600bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1601 uint32_t createInfoCount,
1602 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1603 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001604 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001605 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001606
1607 if (pCreateInfos != nullptr) {
1608 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001609 bool has_dynamic_viewport = false;
1610 bool has_dynamic_scissor = false;
1611 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001612 bool has_dynamic_depth_bias = false;
1613 bool has_dynamic_blend_constant = false;
1614 bool has_dynamic_depth_bounds = false;
1615 bool has_dynamic_stencil_compare = false;
1616 bool has_dynamic_stencil_write = false;
1617 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001618 bool has_dynamic_viewport_w_scaling_nv = false;
1619 bool has_dynamic_discard_rectangle_ext = false;
1620 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001621 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001622 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001623 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001624 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001625 bool has_dynamic_cull_mode = false;
1626 bool has_dynamic_front_face = false;
1627 bool has_dynamic_primitive_topology = false;
1628 bool has_dynamic_viewport_with_count = false;
1629 bool has_dynamic_scissor_with_count = false;
1630 bool has_dynamic_vertex_input_binding_stride = false;
1631 bool has_dynamic_depth_test_enable = false;
1632 bool has_dynamic_depth_write_enable = false;
1633 bool has_dynamic_depth_compare_op = false;
1634 bool has_dynamic_depth_bounds_test_enable = false;
1635 bool has_dynamic_stencil_test_enable = false;
1636 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001637 bool has_patch_control_points = false;
1638 bool has_rasterizer_discard_enable = false;
1639 bool has_depth_bias_enable = false;
1640 bool has_logic_op = false;
1641 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001642 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001643 if (pCreateInfos[i].pDynamicState != nullptr) {
1644 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1645 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1646 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001647 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1648 if (has_dynamic_viewport == true) {
1649 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1650 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1651 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1652 i);
1653 }
1654 has_dynamic_viewport = true;
1655 }
1656 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1657 if (has_dynamic_scissor == true) {
1658 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1659 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1660 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1661 i);
1662 }
1663 has_dynamic_scissor = true;
1664 }
1665 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1666 if (has_dynamic_line_width == true) {
1667 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1668 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1669 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1670 i);
1671 }
1672 has_dynamic_line_width = true;
1673 }
1674 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1675 if (has_dynamic_depth_bias == true) {
1676 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1677 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1678 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1679 i);
1680 }
1681 has_dynamic_depth_bias = true;
1682 }
1683 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1684 if (has_dynamic_blend_constant == true) {
1685 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1686 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1687 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1688 i);
1689 }
1690 has_dynamic_blend_constant = true;
1691 }
1692 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1693 if (has_dynamic_depth_bounds == true) {
1694 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1695 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1696 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1697 i);
1698 }
1699 has_dynamic_depth_bounds = true;
1700 }
1701 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1702 if (has_dynamic_stencil_compare == true) {
1703 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1704 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1705 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1706 i);
1707 }
1708 has_dynamic_stencil_compare = true;
1709 }
1710 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1711 if (has_dynamic_stencil_write == true) {
1712 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1713 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1714 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1715 i);
1716 }
1717 has_dynamic_stencil_write = true;
1718 }
1719 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1720 if (has_dynamic_stencil_reference == true) {
1721 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1722 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1723 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1724 i);
1725 }
1726 has_dynamic_stencil_reference = true;
1727 }
1728 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1729 if (has_dynamic_viewport_w_scaling_nv == true) {
1730 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1731 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1732 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1733 i);
1734 }
1735 has_dynamic_viewport_w_scaling_nv = true;
1736 }
1737 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1738 if (has_dynamic_discard_rectangle_ext == true) {
1739 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1740 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1741 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1742 i);
1743 }
1744 has_dynamic_discard_rectangle_ext = true;
1745 }
1746 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1747 if (has_dynamic_sample_locations_ext == true) {
1748 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1749 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1750 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1751 i);
1752 }
1753 has_dynamic_sample_locations_ext = true;
1754 }
1755 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1756 if (has_dynamic_exclusive_scissor_nv == true) {
1757 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1758 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1759 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1760 i);
1761 }
1762 has_dynamic_exclusive_scissor_nv = true;
1763 }
1764 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1765 if (has_dynamic_shading_rate_palette_nv == true) {
1766 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1767 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1768 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1769 i);
1770 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001771 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001772 }
1773 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1774 if (has_dynamic_viewport_course_sample_order_nv == true) {
1775 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1776 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1777 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1778 i);
1779 }
1780 has_dynamic_viewport_course_sample_order_nv = true;
1781 }
1782 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1783 if (has_dynamic_line_stipple == true) {
1784 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1785 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1786 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1787 i);
1788 }
1789 has_dynamic_line_stipple = true;
1790 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001791 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1792 if (has_dynamic_cull_mode) {
1793 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1794 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1795 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1796 i);
1797 }
1798 has_dynamic_cull_mode = true;
1799 }
1800 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1801 if (has_dynamic_front_face) {
1802 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1803 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1804 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1805 i);
1806 }
1807 has_dynamic_front_face = true;
1808 }
1809 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1810 if (has_dynamic_primitive_topology) {
1811 skip |= LogError(
1812 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1813 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1814 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1815 i);
1816 }
1817 has_dynamic_primitive_topology = true;
1818 }
1819 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1820 if (has_dynamic_viewport_with_count) {
1821 skip |= LogError(
1822 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1823 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1824 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1825 i);
1826 }
1827 has_dynamic_viewport_with_count = true;
1828 }
1829 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1830 if (has_dynamic_scissor_with_count) {
1831 skip |= LogError(
1832 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1833 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1834 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1835 i);
1836 }
1837 has_dynamic_scissor_with_count = true;
1838 }
1839 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1840 if (has_dynamic_vertex_input_binding_stride) {
1841 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1842 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1843 "listed twice in the "
1844 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1845 i);
1846 }
1847 has_dynamic_vertex_input_binding_stride = true;
1848 }
1849 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1850 if (has_dynamic_depth_test_enable) {
1851 skip |= LogError(
1852 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1853 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1854 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1855 i);
1856 }
1857 has_dynamic_depth_test_enable = true;
1858 }
1859 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1860 if (has_dynamic_depth_write_enable) {
1861 skip |= LogError(
1862 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1863 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1864 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1865 i);
1866 }
1867 has_dynamic_depth_write_enable = true;
1868 }
1869 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1870 if (has_dynamic_depth_compare_op) {
1871 skip |=
1872 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1873 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1874 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1875 i);
1876 }
1877 has_dynamic_depth_compare_op = true;
1878 }
1879 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1880 if (has_dynamic_depth_bounds_test_enable) {
1881 skip |= LogError(
1882 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1883 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1884 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1885 i);
1886 }
1887 has_dynamic_depth_bounds_test_enable = true;
1888 }
1889 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1890 if (has_dynamic_stencil_test_enable) {
1891 skip |= LogError(
1892 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1893 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1894 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1895 i);
1896 }
1897 has_dynamic_stencil_test_enable = true;
1898 }
1899 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1900 if (has_dynamic_stencil_op) {
1901 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1902 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1903 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1904 i);
1905 }
1906 has_dynamic_stencil_op = true;
1907 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001908 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1909 // Not allowed for graphics pipelines
1910 skip |= LogError(
1911 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1912 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1913 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1914 i, state_index);
1915 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001916 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1917 if (has_patch_control_points) {
1918 skip |= LogError(
1919 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1920 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1921 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1922 i);
1923 }
1924 has_patch_control_points = true;
1925 }
1926 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1927 if (has_rasterizer_discard_enable) {
1928 skip |= LogError(
1929 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1930 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1931 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1932 i);
1933 }
1934 has_rasterizer_discard_enable = true;
1935 }
1936 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1937 if (has_depth_bias_enable) {
1938 skip |= LogError(
1939 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1940 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1941 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1942 i);
1943 }
1944 has_depth_bias_enable = true;
1945 }
1946 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1947 if (has_logic_op) {
1948 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1949 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1950 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1951 i);
1952 }
1953 has_logic_op = true;
1954 }
1955 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1956 if (has_primitive_restart_enable) {
1957 skip |= LogError(
1958 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1959 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1960 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1961 i);
1962 }
1963 has_primitive_restart_enable = true;
1964 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001965 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1966 if (has_dynamic_vertex_input) {
1967 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1968 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1969 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1970 i);
1971 }
1972 has_dynamic_vertex_input = true;
1973 }
Petr Kraus299ba622017-11-24 03:09:03 +01001974 }
1975 }
1976
sfricke-samsung3b944422021-01-23 02:15:19 -08001977 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1978 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1979 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1980 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1981 i);
1982 }
1983
1984 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1985 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1986 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1987 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1988 i);
1989 }
1990
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001991 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001992 if ((feedback_struct != nullptr) &&
1993 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001994 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1995 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1996 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1997 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1998 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001999 }
2000
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002001 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002002
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002003 // Collect active stages and other information
2004 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002005 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002006 bool has_eval = false;
2007 bool has_control = false;
2008 if (pCreateInfos[i].pStages != nullptr) {
2009 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
2010 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
2011
2012 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
2013 has_control = true;
2014 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
2015 has_eval = true;
2016 }
2017
2018 skip |= validate_string(
2019 "vkCreateGraphicsPipelines",
2020 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2021 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002022
2023 std::stringstream msg;
2024 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2025 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2026 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002027 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002028 }
2029
2030 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2031 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2032 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2033 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2034 pCreateInfos[i].pTessellationState,
2035 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2036 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2037
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002038 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002039 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2040
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002041 skip |= validate_struct_pnext(
2042 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2043 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2044 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2045 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2046 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2047 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002048
2049 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2050 pCreateInfos[i].pTessellationState->flags,
2051 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2052 }
2053
2054 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2055 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2056 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2057 pCreateInfos[i].pInputAssemblyState,
2058 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2059 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2060
2061 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2062 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002063 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002064
2065 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2066 pCreateInfos[i].pInputAssemblyState->flags,
2067 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2068
2069 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2070 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2071 pCreateInfos[i].pInputAssemblyState->topology,
2072 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2073
2074 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2075 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2076 }
2077
2078 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002079 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002080
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002081 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002082 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2083 "vkCreateGraphicsPipelines: pararameter "
2084 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
2085 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002086 }
2087
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002088 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002089 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2090 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2091 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2092 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002093 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2094 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002095 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002096 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2097 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002098 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002099 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2100 skip |=
2101 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2102 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2103 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2104 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2105 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2106
2107 skip |= validate_array(
2108 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2109 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2110 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2111 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2112
2113 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002114 for (uint32_t vertex_binding_description_index = 0;
2115 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2116 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002117 skip |= validate_ranged_enum(
2118 "vkCreateGraphicsPipelines",
2119 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2120 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002121 pCreateInfos[i]
2122 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2123 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002124 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2125 }
2126 }
2127
2128 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002129 for (uint32_t vertex_attribute_description_index = 0;
2130 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2131 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002132 const VkFormat format =
2133 pCreateInfos[i]
2134 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2135 .format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002136 skip |= validate_ranged_enum(
2137 "vkCreateGraphicsPipelines",
2138 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2139 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002140 pCreateInfos[i]
2141 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2142 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002143 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002144 if (FormatIsDepthOrStencil(format)) {
2145 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2146 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2147 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2148 "vkCreateGraphicsPipelines: "
2149 "pCreateInfos[%d].pVertexInputState->pVertexAttributeDescriptions[%d].format is a "
2150 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2151 "alignment, replace with a color format.",
2152 i, vertex_attribute_description_index, string_VkFormat(format));
2153 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002154 }
2155 }
2156
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002157 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002158 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2159 "vkCreateGraphicsPipelines: pararameter "
2160 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2161 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2162 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002163 }
2164
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002165 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002166 skip |=
2167 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2168 "vkCreateGraphicsPipelines: pararameter "
2169 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2170 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2171 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002172 }
2173
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002174 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002175 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2176 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002177 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2178 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002179 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2180 "vkCreateGraphicsPipelines: parameter "
2181 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2182 "(%" PRIu32 ") is not distinct.",
2183 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002184 }
2185 vertex_bindings.insert(vertex_bind_desc.binding);
2186
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002187 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002188 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2189 "vkCreateGraphicsPipelines: parameter "
2190 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2191 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2192 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002193 }
2194
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002195 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002196 skip |=
2197 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2198 "vkCreateGraphicsPipelines: parameter "
2199 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2200 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2201 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002202 }
2203 }
2204
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002205 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002206 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2207 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002208 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2209 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002210 skip |= LogError(
2211 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002212 "vkCreateGraphicsPipelines: parameter "
2213 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2214 i, d, vertex_attrib_desc.location);
2215 }
2216 attribute_locations.insert(vertex_attrib_desc.location);
2217
2218 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2219 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002220 skip |= LogError(
2221 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002222 "vkCreateGraphicsPipelines: parameter "
2223 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2224 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2225 i, d, vertex_attrib_desc.binding, i);
2226 }
2227
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002228 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002229 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2230 "vkCreateGraphicsPipelines: parameter "
2231 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2232 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2233 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002234 }
2235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002236 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002237 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2238 "vkCreateGraphicsPipelines: parameter "
2239 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2240 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2241 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002242 }
2243
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002244 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002245 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2246 "vkCreateGraphicsPipelines: parameter "
2247 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2248 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2249 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002250 }
2251 }
2252 }
2253
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002254 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2255 if (has_control && has_eval) {
2256 if (pCreateInfos[i].pTessellationState == nullptr) {
2257 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2258 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2259 "shader stage and a tessellation evaluation shader stage, "
2260 "pCreateInfos[%d].pTessellationState must not be NULL.",
2261 i, i);
2262 } else {
2263 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2264 skip |= validate_struct_pnext(
2265 "vkCreateGraphicsPipelines",
2266 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2267 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2268 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2269 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002271 skip |= validate_reserved_flags(
2272 "vkCreateGraphicsPipelines",
2273 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2274 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002275
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002276 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2277 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2278 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2279 "vkCreateGraphicsPipelines: invalid parameter "
2280 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2281 "should be >0 and <=%u.",
2282 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2283 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002284 }
2285 }
2286 }
2287
2288 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2289 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2290 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2291 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002292 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2293 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2294 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2295 "].pViewportState (=NULL) is not a valid pointer.",
2296 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002297 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002298 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2299
2300 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002301 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2302 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2303 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2304 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002305 }
2306
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002307 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002308 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002309 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2310 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002311 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2312 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002313 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002314 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002315 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002316 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002317 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002318 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2319 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002320 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2321 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2322 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002323 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002324
2325 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002326 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002327 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002328 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002329
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002330 auto exclusive_scissor_struct =
2331 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2332 auto shading_rate_image_struct =
2333 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2334 auto coarse_sample_order_struct =
2335 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002336 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002337 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002338 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002339 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002340
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002341 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002342 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002343 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2344 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2345 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2346 ") is not 1.",
2347 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002348 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002349
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002350 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002351 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2352 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2353 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2354 ") is not 1.",
2355 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002356 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002357
Dave Houlton142c4cb2018-10-17 15:04:41 -06002358 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2359 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002360 skip |= LogError(
2361 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2362 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2363 "disabled, but pCreateInfos[%" PRIu32
2364 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2365 ") is not 1.",
2366 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002367 }
2368
Jeff Bolz9af91c52018-09-01 21:53:57 -05002369 if (shading_rate_image_struct &&
2370 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002371 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2372 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2373 "disabled, but pCreateInfos[%" PRIu32
2374 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2375 ") is neither 0 nor 1.",
2376 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002377 }
2378
Petr Krausa6103552017-11-16 21:21:58 +01002379 } else { // multiViewport enabled
2380 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002381 if (!has_dynamic_viewport_with_count) {
2382 skip |= LogError(
2383 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2384 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2385 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002386 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002387 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2388 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2389 "].pViewportState->viewportCount (=%" PRIu32
2390 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2391 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002392 } else if (has_dynamic_viewport_with_count) {
2393 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2394 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2395 "].pViewportState->viewportCount (=%" PRIu32
2396 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2397 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002398 }
Petr Krausa6103552017-11-16 21:21:58 +01002399
2400 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002401 if (!has_dynamic_scissor_with_count) {
2402 skip |= LogError(
2403 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2404 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2405 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002406 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002407 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2408 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2409 "].pViewportState->scissorCount (=%" PRIu32
2410 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2411 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002412 } else if (has_dynamic_scissor_with_count) {
2413 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2414 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2415 "].pViewportState->scissorCount (=%" PRIu32
2416 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2417 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002418 }
2419 }
2420
ziga-lunarg845883b2021-07-14 15:05:00 +02002421 if (!has_dynamic_scissor && viewport_state.pScissors) {
2422 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2423 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002424
2425 if (scissor.offset.x < 0) {
2426 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2427 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2428 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2429 scissor.offset.x, i, scissor_i);
2430 }
2431
2432 if (scissor.offset.y < 0) {
2433 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2434 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2435 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2436 scissor.offset.y, i, scissor_i);
2437 }
2438
ziga-lunarg845883b2021-07-14 15:05:00 +02002439 const int64_t x_sum =
2440 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2441 if (x_sum > std::numeric_limits<int32_t>::max()) {
2442 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2443 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2444 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2445 "] will overflow int32_t.",
2446 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2447 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002448
ziga-lunarg845883b2021-07-14 15:05:00 +02002449 const int64_t y_sum =
2450 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2451 if (y_sum > std::numeric_limits<int32_t>::max()) {
2452 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2453 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2454 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2455 "] will overflow int32_t.",
2456 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2457 }
2458 }
2459 }
2460
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002461 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002462 skip |=
2463 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2464 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2465 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2466 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002467 }
2468
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002469 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002470 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2471 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2472 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2473 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2474 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002475 }
2476
Piers Daniell39842ee2020-07-10 16:42:33 -06002477 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2478 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002479 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2480 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2481 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2482 "].pViewportState->viewportCount (=%" PRIu32 ").",
2483 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002484 }
2485
Dave Houlton142c4cb2018-10-17 15:04:41 -06002486 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002487 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002488 skip |=
2489 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2490 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2491 ") must be zero or identical to pCreateInfos[%" PRIu32
2492 "].pViewportState->viewportCount (=%" PRIu32 ").",
2493 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002494 }
2495
Dave Houlton142c4cb2018-10-17 15:04:41 -06002496 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002497 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002498 skip |= LogError(
2499 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002500 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2501 "] "
2502 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2503 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2504 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002505 }
2506
Petr Krausa6103552017-11-16 21:21:58 +01002507 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002508 skip |= LogError(
2509 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002510 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2511 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002512 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2513 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002514 }
2515
2516 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002517 skip |= LogError(
2518 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002519 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2520 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002521 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2522 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002523 }
2524
Jeff Bolz3e71f782018-08-29 23:15:45 -05002525 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002526 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2527 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2528 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002529 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002530 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2531 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2532 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2533 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002534 }
2535
Jeff Bolz9af91c52018-09-01 21:53:57 -05002536 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002537 shading_rate_image_struct->viewportCount > 0 &&
2538 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002539 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002540 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002541 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002542 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2543 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002544 i, i);
2545 }
2546
Chris Mayer328d8212018-12-11 14:16:18 +01002547 if (vp_swizzle_struct) {
2548 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002549 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2550 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2551 " does "
2552 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2553 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002554 }
2555 }
2556
Petr Krausb3fcdb42018-01-09 22:09:09 +01002557 // validate the VkViewports
2558 if (!has_dynamic_viewport && viewport_state.pViewports) {
2559 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2560 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002561 const char *fn_name = "vkCreateGraphicsPipelines";
2562 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2563 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2564 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002565 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002566 }
2567 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002568
sfricke-samsung45996a42021-09-16 13:45:27 -07002569 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002570 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2571 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2572 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2573 "VK_NV_clip_space_w_scaling extension is not enabled.",
2574 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002575 }
2576
sfricke-samsung45996a42021-09-16 13:45:27 -07002577 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002578 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2579 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2580 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2581 "VK_EXT_discard_rectangles extension is not enabled.",
2582 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002583 }
2584
sfricke-samsung45996a42021-09-16 13:45:27 -07002585 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002586 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2587 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2588 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2589 "VK_EXT_sample_locations extension is not enabled.",
2590 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002591 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002592
sfricke-samsung45996a42021-09-16 13:45:27 -07002593 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002594 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2595 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2596 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2597 "VK_NV_scissor_exclusive extension is not enabled.",
2598 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002599 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002600
2601 if (coarse_sample_order_struct &&
2602 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2603 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002604 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2605 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2606 "] "
2607 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2608 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2609 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002610 }
2611
2612 if (coarse_sample_order_struct) {
2613 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002614 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002615 }
2616 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002617
2618 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2619 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002620 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2621 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2622 "] "
2623 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2624 ") "
2625 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2626 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002627 }
2628 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002629 skip |= LogError(
2630 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002631 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2632 "] "
2633 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2634 i);
2635 }
2636 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002637 }
2638
2639 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002640 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2641 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2642 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2643 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002644 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002645 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002646 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002647 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2648 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002649 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002650 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002651 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002652 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002653 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002654 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002655 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002656 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2657 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002658
2659 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002660 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002661 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002662 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002663
2664 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002665 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002666 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2667 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2668
2669 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002670 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002671 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2672 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002673 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002674 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002675
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002676 skip |= validate_flags(
2677 "vkCreateGraphicsPipelines",
2678 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2679 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002680 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002681
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002682 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002683 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002684 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2685 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2686
2687 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002688 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002689 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2690 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2691
2692 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002693 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002694 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2695 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2696 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002697 }
John Zulauf7acac592017-11-06 11:15:53 -07002698 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002699 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002700 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2701 "vkCreateGraphicsPipelines(): parameter "
2702 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2703 i);
John Zulauf7acac592017-11-06 11:15:53 -07002704 }
2705 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2706 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2707 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002708 skip |= LogError(
2709 device,
2710
Dave Houlton413a6782018-05-22 13:01:54 -06002711 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002712 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002713 }
2714 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002715
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002716 const auto *line_state =
2717 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002718
2719 if (line_state) {
2720 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2721 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2722 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2723 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002724 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2725 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2726 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2727 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002728 }
2729 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2730 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002731 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2732 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2733 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2734 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002735 }
2736 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2737 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002738 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2739 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2740 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2741 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002742 }
2743 }
2744 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2745 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2746 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002747 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2748 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2749 "range [1,256].",
2750 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002751 }
2752 }
2753 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002754 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002755 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2756 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002757 skip |=
2758 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2759 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2760 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2761 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002762 }
2763 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2764 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002765 skip |=
2766 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2767 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2768 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2769 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002770 }
2771 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2772 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002773 skip |=
2774 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2775 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2776 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2777 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002778 }
2779 if (line_state->stippledLineEnable) {
2780 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2781 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002782 skip |=
2783 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2784 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2785 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2786 "stippledRectangularLines feature.",
2787 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002788 }
2789 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2790 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002791 skip |=
2792 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2793 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2794 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2795 "stippledBresenhamLines feature.",
2796 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002797 }
2798 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2799 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002800 skip |=
2801 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2802 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2803 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2804 "stippledSmoothLines feature.",
2805 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002806 }
2807 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2808 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002809 skip |=
2810 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2811 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2812 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2813 "stippledRectangularLines and strictLines features.",
2814 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002815 }
2816 }
2817 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002818 }
2819
Petr Krause91f7a12017-12-14 20:57:36 +01002820 bool uses_color_attachment = false;
2821 bool uses_depthstencil_attachment = false;
2822 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002823 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002824 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2825 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002826 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002827 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002828 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002829 }
2830 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002831 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002832 }
Petr Krause91f7a12017-12-14 20:57:36 +01002833 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002834 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002835 }
2836
2837 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002838 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002839 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002840 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002841 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002842 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002843
2844 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002845 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002846 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002847 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002848
2849 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002850 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002851 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2852 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2853
2854 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002855 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002856 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2857 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2858
2859 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002860 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002861 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2862 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002863 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002864
2865 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002866 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2868 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2869
2870 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002871 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002872 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2873 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2874
2875 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002876 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002877 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2878 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002879 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002880
2881 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002882 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002883 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2884 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002885 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002886
2887 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002888 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002889 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2890 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002891 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892
2893 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002894 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002895 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2896 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002897 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002898
2899 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002900 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002901 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2902 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002903 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002904
2905 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002906 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002907 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2908 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002909 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002910
2911 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002912 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002913 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2914 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002915 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002916
2917 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002918 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002919 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2920 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002921 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002922
2923 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002924 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002925 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2926 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2927 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002928 }
2929 }
2930
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002931 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02002932 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
2933 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002934
Petr Krause91f7a12017-12-14 20:57:36 +01002935 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002936 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2937 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2938 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2939 pCreateInfos[i].pColorBlendState,
2940 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2941 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2942
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002943 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002944 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002945 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
ziga-lunarg8de09162021-08-05 15:21:33 +02002946 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002947 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2948 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002949 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2950 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002951
2952 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002953 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002954 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002955 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956
2957 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002958 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002959 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2960 pCreateInfos[i].pColorBlendState->logicOpEnable);
2961
2962 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002963 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2965 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002966 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002967 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968
2969 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002970 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2971 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002972 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002974 ParameterName::IndexVector{i, attachment_index}),
2975 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002976
2977 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002978 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002979 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002980 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002981 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002982 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002983 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002984
2985 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002986 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002988 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002990 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002991 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002992
2993 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002994 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002996 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002997 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002998 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002999 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000
3001 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003002 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003004 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003005 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003006 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003007 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003008
3009 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003010 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003011 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003012 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003013 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003014 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003015 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003016
3017 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003018 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003019 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003020 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003021 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003022 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003023 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003024
3025 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003026 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003027 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003028 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003029 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003030 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003031 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003032
3033 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3034 bool invalid = false;
3035 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3036 case VK_BLEND_OP_ZERO_EXT:
3037 case VK_BLEND_OP_SRC_EXT:
3038 case VK_BLEND_OP_DST_EXT:
3039 case VK_BLEND_OP_SRC_OVER_EXT:
3040 case VK_BLEND_OP_DST_OVER_EXT:
3041 case VK_BLEND_OP_SRC_IN_EXT:
3042 case VK_BLEND_OP_DST_IN_EXT:
3043 case VK_BLEND_OP_SRC_OUT_EXT:
3044 case VK_BLEND_OP_DST_OUT_EXT:
3045 case VK_BLEND_OP_SRC_ATOP_EXT:
3046 case VK_BLEND_OP_DST_ATOP_EXT:
3047 case VK_BLEND_OP_XOR_EXT:
3048 case VK_BLEND_OP_INVERT_EXT:
3049 case VK_BLEND_OP_INVERT_RGB_EXT:
3050 case VK_BLEND_OP_LINEARDODGE_EXT:
3051 case VK_BLEND_OP_LINEARBURN_EXT:
3052 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3053 case VK_BLEND_OP_LINEARLIGHT_EXT:
3054 case VK_BLEND_OP_PINLIGHT_EXT:
3055 case VK_BLEND_OP_HARDMIX_EXT:
3056 case VK_BLEND_OP_PLUS_EXT:
3057 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3058 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3059 case VK_BLEND_OP_PLUS_DARKER_EXT:
3060 case VK_BLEND_OP_MINUS_EXT:
3061 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3062 case VK_BLEND_OP_CONTRAST_EXT:
3063 case VK_BLEND_OP_INVERT_OVG_EXT:
3064 case VK_BLEND_OP_RED_EXT:
3065 case VK_BLEND_OP_GREEN_EXT:
3066 case VK_BLEND_OP_BLUE_EXT:
3067 invalid = true;
3068 break;
3069 default:
3070 break;
3071 }
3072 if (invalid) {
3073 skip |= LogError(
3074 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3075 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3076 "].pColorBlendState->pAttachments[%" PRIu32
3077 "].colorBlendOp (%s) is not valid when "
3078 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3079 "VK_FALSE",
3080 i, attachment_index,
3081 string_VkBlendOp(
3082 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3083 }
3084 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003085 }
3086 }
3087
3088 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003089 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003090 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
3091 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3092 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003093 }
3094
3095 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3096 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3097 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003098 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003099 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003100 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3101 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003102 }
3103 }
3104 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003105
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003106 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3107 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003108 if (pCreateInfos[i].basePipelineIndex != -1) {
3109 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003110 skip |=
3111 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003112 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003113 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003114 "and pCreateInfos->basePipelineIndex is not -1.",
3115 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003116 }
3117 }
3118
Petr Kraus9752aae2017-11-24 03:05:50 +01003119 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3120 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003121 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003122 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003123 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003124 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3125 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003126 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003127 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003128 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003129 skip |=
3130 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
3131 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
3132 "index into the pCreateInfos array, of size %d.",
3133 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003134 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003135 }
3136 }
3137
Petr Kraus9752aae2017-11-24 03:05:50 +01003138 if (pCreateInfos[i].pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003139 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003140 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3141 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003142 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3143 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3144 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3145 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003146 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3147 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003148 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003149 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003150 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
3151 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3152 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003153 }
3154 } else {
3155 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3156 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3157 (physical_device_features.fillModeNonSolid == false)) {
3158 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003159 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3160 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003161 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
3162 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3163 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003164 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003165 }
Petr Kraus299ba622017-11-24 03:09:03 +01003166
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003167 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003168 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003169 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3170 "The line width state is static (pCreateInfos[%" PRIu32
3171 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3172 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3173 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3174 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003175 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003176 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003177
3178 // Validate no flags not allowed are used
3179 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003180 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
3181 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3182 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3183 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003184 }
3185 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003186 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
3187 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3188 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3189 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003190 }
3191 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3192 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07003193 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3194 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3195 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003196 }
3197 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3198 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07003199 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3200 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3201 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003202 }
3203 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3204 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07003205 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3206 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3207 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003208 }
3209 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3210 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003211 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3212 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3213 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003214 }
3215 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3216 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003217 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3218 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3219 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003220 }
3221 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3222 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003223 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3224 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3225 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003226 }
3227 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3228 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003229 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3230 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3231 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003232 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003233 }
3234 }
3235
3236 return skip;
3237}
3238
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003239bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3240 uint32_t createInfoCount,
3241 const VkComputePipelineCreateInfo *pCreateInfos,
3242 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003243 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003244 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003245 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003246 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003247 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003248 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003249 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003250 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003251 skip |=
3252 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3253 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3254 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3255 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003256 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003257
3258 // Make sure compute stage is selected
3259 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003260 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3261 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3262 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003263 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003264
sfricke-samsungeb549012021-04-16 01:25:51 -07003265 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3266 // Validate no flags not allowed are used
3267 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3268 skip |= LogError(
3269 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3270 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3271 i, flags);
3272 }
3273 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3274 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3275 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3276 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3277 i, flags);
3278 }
3279 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3280 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3281 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3282 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3283 i, flags);
3284 }
3285 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3286 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3287 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3288 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3289 i, flags);
3290 }
3291 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3292 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3293 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3294 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3295 i, flags);
3296 }
3297 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3298 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3299 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3300 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3301 i, flags);
3302 }
3303 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3304 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3305 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3306 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3307 i, flags);
3308 }
3309 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3310 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3311 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3312 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3313 i, flags);
3314 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003315 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3316 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
3317 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3318 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3319 i, flags);
3320 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003321 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3322 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3323 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3324 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3325 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003326 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003327 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3328 if (pCreateInfos[i].basePipelineIndex != -1) {
3329 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3330 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3331 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3332 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3333 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3334 i);
3335 }
3336 }
3337
3338 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3339 if (pCreateInfos[i].basePipelineIndex != -1) {
3340 skip |= LogError(
3341 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3342 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3343 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3344 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3345 i);
3346 }
3347 } else {
3348 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3349 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3350 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3351 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3352 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3353 }
3354 }
3355 }
ziga-lunargc6341372021-07-28 12:57:42 +02003356
3357 std::stringstream msg;
3358 msg << "pCreateInfos[%" << i << "].stage";
3359 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003360 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003361 return skip;
3362}
3363
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003364bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003365 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003366 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003367
3368 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003369 const auto &features = physical_device_features;
3370 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003371
John Zulauf71968502017-10-26 13:51:15 -06003372 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3373 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003374 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3375 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3376 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3377 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003378 }
3379
3380 // Anistropy cannot be enabled in sampler unless enabled as a feature
3381 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003382 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3383 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3384 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003385 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003386 }
John Zulauf71968502017-10-26 13:51:15 -06003387
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003388 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3389 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003390 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3391 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3392 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3393 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003394 }
3395 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003396 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3397 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3398 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3399 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003400 }
3401 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003402 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3403 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3404 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3405 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003406 }
3407 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3408 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3409 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3410 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003411 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3412 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3413 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3414 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3415 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3416 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003417 }
3418 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003419 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3420 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3421 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003422 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003423 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003424 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3425 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3426 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003427 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003428 }
3429
3430 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3431 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003432 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3433 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003434 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003435 if (sampler_reduction != nullptr) {
3436 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3437 skip |= LogError(
3438 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3439 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3440 }
3441 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003442 }
3443
3444 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3445 // valid VkBorderColor value
3446 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3447 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3448 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003449 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3450 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003451 }
3452
John Zulauf275805c2017-10-26 15:34:49 -06003453 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003454 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003455 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3456 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003457 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3458 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3459 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003460 }
3461 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003462
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003463 // Check for valid Lod range
3464 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003465 skip |=
3466 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3467 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003468 }
3469
3470 // Check mipLodBias to device limit
3471 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003472 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3473 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3474 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003475 }
3476
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003477 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003478 if (sampler_conversion != nullptr) {
3479 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3480 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3481 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3482 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003483 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003484 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003485 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3486 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3487 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3488 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3489 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3490 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3491 }
3492 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003493
3494 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3495 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3496 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3497 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3498 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3499 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3500 }
3501 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3502 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3503 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3504 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3505 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3506 }
3507 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3508 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3509 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3510 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3511 pCreateInfo->minLod, pCreateInfo->maxLod);
3512 }
3513 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3514 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3515 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3516 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3517 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3518 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3519 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3520 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3521 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3522 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3523 }
3524 if (pCreateInfo->anisotropyEnable) {
3525 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3526 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3527 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3528 }
3529 if (pCreateInfo->compareEnable) {
3530 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3531 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3532 "pCreateInfo->compareEnable must be VK_FALSE");
3533 }
3534 if (pCreateInfo->unnormalizedCoordinates) {
3535 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3536 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3537 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3538 }
3539 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003540 }
3541
Tony-LunarG7337b312020-04-15 16:40:25 -06003542 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3543 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003544 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
Tony-LunarG7337b312020-04-15 16:40:25 -06003545 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3546 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3547 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3548 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003549 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003550 if (!custom_create_info) {
3551 skip |=
3552 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3553 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3554 "struct in pNext chain.\n",
3555 string_VkBorderColor(pCreateInfo->borderColor));
3556 } else {
3557 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3558 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3559 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3560 !FormatIsSampledFloat(custom_create_info->format)))) {
3561 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3562 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3563 "whose type does not match\n",
3564 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3565 ;
3566 }
3567 }
3568 }
3569
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003570 return skip;
3571}
3572
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003573bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3574 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3575 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003576 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003577 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003578
3579 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3580 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3581 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3582 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003583 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3584 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3585 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3586 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3587 ++descriptor_index) {
3588 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003589 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003590 "vkCreateDescriptorSetLayout: required parameter "
3591 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3592 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003593 }
3594 }
3595 }
3596
3597 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3598 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3599 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003600 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3601 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3602 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3603 "values.",
3604 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003605 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003606
3607 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3608 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3609 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3610 skip |=
3611 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3612 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3613 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3614 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3615 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3616 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003617 }
3618 }
3619 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003620 return skip;
3621}
3622
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003623bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3624 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003625 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003626 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3627 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3628 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003629 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3630 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003631}
3632
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003633bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3634 const VkWriteDescriptorSet *pDescriptorWrites,
3635 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003636 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003637
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003638 if (pDescriptorWrites != NULL) {
3639 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3640 // descriptorCount must be greater than 0
3641 if (pDescriptorWrites[i].descriptorCount == 0) {
3642 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003643 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3644 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003645 }
3646
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003647 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3648 if (validateDstSet) {
3649 // dstSet must be a valid VkDescriptorSet handle
3650 skip |= validate_required_handle(vkCallingFunction,
3651 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3652 pDescriptorWrites[i].dstSet);
3653 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003654
3655 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3656 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3657 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3658 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3659 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3660 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3661 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003662 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3663 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003664 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003665 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3666 "%s(): if pDescriptorWrites[%d].descriptorType is "
3667 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3668 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3669 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3670 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003671 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3672 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003673 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3674 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003675 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3676 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003677 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003678 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3679 ParameterName::IndexVector{i, descriptor_index}),
3680 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003681 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003682 }
3683 }
3684 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3685 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3686 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3687 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3688 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3689 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3690 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003691 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003692 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003693 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3694 "%s(): if pDescriptorWrites[%d].descriptorType is "
3695 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3696 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3697 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3698 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003699 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003700 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003701 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003702 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003703 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3704 ++descriptor_index) {
3705 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3706 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3707 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003708 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3709 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003710 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003711 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3712 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003713 }
3714 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003715 }
3716 }
3717 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3718 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003719 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003720 }
3721
3722 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3723 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003724 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003725 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3726 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003727 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003728 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003729 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3730 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3731 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003732 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003733 }
3734 }
3735 }
3736 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3737 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003738 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003739 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3740 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003741 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003742 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003743 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3744 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3745 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003746 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003747 }
3748 }
3749 }
3750 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003751 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3752 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003753 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003754 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003755 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3756 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3757 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3758 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3759 "accelerationStructureCount %d member equals descriptorCount %d.",
3760 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3761 pDescriptorWrites[i].descriptorCount);
3762 }
3763 // further checks only if we have right structtype
3764 if (pnext_struct) {
3765 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3766 skip |= LogError(
3767 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3768 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3769 ".",
3770 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003771 }
sourav parmarbcee7512020-12-28 14:34:49 -08003772 if (pnext_struct->accelerationStructureCount == 0) {
3773 skip |= LogError(device,
3774 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003775 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003776 }
3777 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003778 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003779 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3780 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3781 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3782 skip |= LogError(device,
3783 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3784 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003785 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003786 }
3787 }
3788 }
sourav parmarbcee7512020-12-28 14:34:49 -08003789 }
3790 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003791 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003792 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3793 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3794 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3795 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3796 "accelerationStructureCount %d member equals descriptorCount %d.",
3797 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3798 pDescriptorWrites[i].descriptorCount);
3799 }
3800 // further checks only if we have right structtype
3801 if (pnext_struct) {
3802 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3803 skip |= LogError(
3804 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3805 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3806 ".",
3807 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003808 }
sourav parmarbcee7512020-12-28 14:34:49 -08003809 if (pnext_struct->accelerationStructureCount == 0) {
3810 skip |= LogError(device,
3811 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003812 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003813 }
3814 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003815 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003816 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3817 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3818 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3819 skip |= LogError(device,
3820 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3821 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003822 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003823 }
3824 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003825 }
3826 }
3827 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003828 }
3829 }
3830 return skip;
3831}
3832
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003833bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3834 const VkWriteDescriptorSet *pDescriptorWrites,
3835 uint32_t descriptorCopyCount,
3836 const VkCopyDescriptorSet *pDescriptorCopies) const {
3837 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3838}
3839
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003840bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003841 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003842 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003843 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3844}
3845
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003846bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3847 const VkAllocationCallbacks *pAllocator,
3848 VkRenderPass *pRenderPass) const {
3849 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3850}
3851
Mike Schuchardt2df08912020-12-15 16:28:09 -08003852bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003853 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003854 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003855 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3856}
3857
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003858bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3859 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003860 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003861 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003862
3863 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3864 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3865 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003866 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3867 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003868 return skip;
3869}
3870
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003871bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003872 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003873 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003874
3875 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3876 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003877 bool cb_is_secondary;
3878 {
3879 auto lock = cb_read_lock();
3880 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3881 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003882
Tony-LunarG3c287f62020-12-17 12:39:49 -07003883 if (cb_is_secondary) {
3884 // Implicit VUs
3885 // validate only sType here; pointer has to be validated in core_validation
3886 const bool k_not_required = false;
3887 const char *k_no_vuid = nullptr;
3888 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3889 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003890 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3891 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003892
Tony-LunarG3c287f62020-12-17 12:39:49 -07003893 if (info) {
3894 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003895 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3896 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003897 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003898 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3899 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3900 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3901 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003902
Tony-LunarG3c287f62020-12-17 12:39:49 -07003903 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003904
Tony-LunarG3c287f62020-12-17 12:39:49 -07003905 // Explicit VUs
3906 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003907 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003908 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3909 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3910 cmd_name);
3911 }
3912
3913 if (physical_device_features.inheritedQueries) {
3914 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003915 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3916 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3917 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003918 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003919 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003920 }
3921
3922 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003923 skip |=
3924 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3925 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3926 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3927 } else { // !pipelineStatisticsQuery
3928 skip |=
3929 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3930 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003931 }
3932
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003933 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003934 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003935 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003936 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3937 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3938 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003939 commandBuffer,
3940 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003941 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3942 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3943 }
Petr Kraus139757b2019-08-15 17:19:33 +02003944 }
ziga-lunarg9d019132021-07-19 01:05:31 +02003945
3946 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
3947 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
3948 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
3949 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
3950 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
3951 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
3952 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
3953 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
3954 }
Petr Kraus139757b2019-08-15 17:19:33 +02003955 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003956 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003957 return skip;
3958}
3959
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003960bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003961 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003962 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003963
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003964 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003965 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003966 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3967 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3968 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003969 }
3970 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003971 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3972 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3973 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003974 }
3975 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003976 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003977 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003978 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3979 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3980 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3981 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003982 }
3983 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003984
3985 if (pViewports) {
3986 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3987 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003988 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003989 skip |= manual_PreCallValidateViewport(
3990 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003991 }
3992 }
3993
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003994 return skip;
3995}
3996
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003997bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003998 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003999 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004000
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004001 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004002 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004003 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4004 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4005 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004006 }
4007 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004008 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4009 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4010 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004011 }
4012 } else { // multiViewport enabled
4013 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004014 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004015 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4016 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4017 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4018 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004019 }
4020 }
4021
Petr Kraus6260f0a2018-02-27 21:15:55 +01004022 if (pScissors) {
4023 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4024 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004025
Petr Kraus6260f0a2018-02-27 21:15:55 +01004026 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004027 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4028 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4029 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004030 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004031
Petr Kraus6260f0a2018-02-27 21:15:55 +01004032 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004033 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4034 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4035 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004036 }
4037
4038 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4039 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004040 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4041 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4042 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4043 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004044 }
4045
4046 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4047 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004048 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4049 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4050 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4051 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004052 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004053 }
4054 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004055
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004056 return skip;
4057}
4058
Jeff Bolz5c801d12019-10-09 10:38:45 -05004059bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004060 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004061
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004062 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004063 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4064 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004065 }
4066
4067 return skip;
4068}
4069
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004070bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004071 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004072 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004073
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004074 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004075 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004076 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
4077 }
4078 if (drawCount > device_limits.maxDrawIndirectCount) {
4079 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004080 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
4081 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004082 }
4083 return skip;
4084}
4085
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004086bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004087 VkDeviceSize offset, uint32_t drawCount,
4088 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004089 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004090 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004091 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4092 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
4093 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004094 }
4095 if (drawCount > device_limits.maxDrawIndirectCount) {
4096 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004097 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4098 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004099 }
4100 return skip;
4101}
4102
sfricke-samsungf692b972020-05-02 08:00:45 -07004103bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4104 VkDeviceSize countBufferOffset, bool khr) const {
4105 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004106 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004107 if (offset & 3) {
4108 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004109 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004110 }
4111
4112 if (countBufferOffset & 3) {
4113 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004114 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004115 countBufferOffset);
4116 }
4117 return skip;
4118}
4119
4120bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4121 VkDeviceSize offset, VkBuffer countBuffer,
4122 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4123 uint32_t stride) const {
4124 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4125}
4126
4127bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4128 VkDeviceSize offset, VkBuffer countBuffer,
4129 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4130 uint32_t stride) const {
4131 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4132}
4133
4134bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4135 VkDeviceSize countBufferOffset, bool khr) const {
4136 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004137 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004138 if (offset & 3) {
4139 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004140 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004141 }
4142
4143 if (countBufferOffset & 3) {
4144 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004145 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004146 countBufferOffset);
4147 }
4148 return skip;
4149}
4150
4151bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4152 VkDeviceSize offset, VkBuffer countBuffer,
4153 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4154 uint32_t stride) const {
4155 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4156}
4157
4158bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4159 VkDeviceSize offset, VkBuffer countBuffer,
4160 VkDeviceSize countBufferOffset,
4161 uint32_t maxDrawCount, uint32_t stride) const {
4162 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4163}
4164
Tony-LunarG4490de42021-06-21 15:49:19 -06004165bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4166 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4167 uint32_t firstInstance, uint32_t stride) const {
4168 bool skip = false;
4169 if (stride & 3) {
4170 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4171 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4172 }
4173 if (drawCount && nullptr == pVertexInfo) {
4174 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4175 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4176 "one or more valid instances of VkMultiDrawInfoEXT structures");
4177 }
4178 return skip;
4179}
4180
4181bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4182 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4183 uint32_t instanceCount, uint32_t firstInstance,
4184 uint32_t stride, const int32_t *pVertexOffset) const {
4185 bool skip = false;
4186 if (stride & 3) {
4187 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4188 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4189 }
4190 if (drawCount && nullptr == pIndexInfo) {
4191 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4192 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4193 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4194 }
4195 return skip;
4196}
4197
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004198bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4199 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004200 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004201 bool skip = false;
4202 for (uint32_t rect = 0; rect < rectCount; rect++) {
4203 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004204 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
4205 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004206 }
sfricke-samsung10867682020-04-25 02:20:39 -07004207 if (pRects[rect].rect.extent.width == 0) {
4208 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
4209 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
4210 }
4211 if (pRects[rect].rect.extent.height == 0) {
4212 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
4213 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
4214 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004215 }
4216 return skip;
4217}
4218
Andrew Fobel3abeb992020-01-20 16:33:22 -05004219bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4220 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4221 VkImageFormatProperties2 *pImageFormatProperties,
4222 const char *apiName) const {
4223 bool skip = false;
4224
4225 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004226 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004227 if (image_stencil_struct != nullptr) {
4228 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4229 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4230 // No flags other than the legal attachment bits may be set
4231 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4232 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004233 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4234 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4235 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4236 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4237 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004238 }
4239 }
4240 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004241 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4242 if (image_drm_format) {
4243 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4244 skip |= LogError(
4245 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4246 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4247 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4248 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4249 }
4250 } else {
4251 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4252 skip |= LogError(
4253 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4254 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4255 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4256 apiName);
4257 }
4258 }
4259 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4260 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4261 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4262 if (!format_list || format_list->viewFormatCount == 0) {
4263 skip |= LogError(
4264 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4265 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4266 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4267 apiName);
4268 }
4269 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004270 }
4271
4272 return skip;
4273}
4274
4275bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4276 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4277 VkImageFormatProperties2 *pImageFormatProperties) const {
4278 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4279 "vkGetPhysicalDeviceImageFormatProperties2");
4280}
4281
4282bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4283 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4284 VkImageFormatProperties2 *pImageFormatProperties) const {
4285 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4286 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4287}
4288
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004289bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4290 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4291 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4292 bool skip = false;
4293
4294 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4295 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4296 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4297 }
4298
4299 return skip;
4300}
4301
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004302bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4303 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4304 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4305 bool skip = false;
4306
4307 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4308 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4309 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4310 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4311 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4312 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4313 }
4314
ziga-lunarg42f884b2021-08-25 16:13:20 +02004315 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004316}
4317
sfricke-samsung3999ef62020-02-09 17:05:59 -08004318bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4319 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4320 bool skip = false;
4321
4322 if (pRegions != nullptr) {
4323 for (uint32_t i = 0; i < regionCount; i++) {
4324 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004325 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4326 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004327 }
4328 }
4329 }
4330 return skip;
4331}
4332
Jeff Leger178b1e52020-10-05 12:22:23 -04004333bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4334 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4335 bool skip = false;
4336
4337 if (pCopyBufferInfo->pRegions != nullptr) {
4338 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4339 if (pCopyBufferInfo->pRegions[i].size == 0) {
4340 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4341 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4342 }
4343 }
4344 }
4345 return skip;
4346}
4347
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004348bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004349 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4350 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004351 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004352
4353 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004354 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4355 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4356 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004357 }
4358
4359 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004360 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4361 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4362 "), must be greater than zero and less than or equal to 65536.",
4363 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004364 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004365 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4366 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4367 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004368 }
4369 return skip;
4370}
4371
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004372bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004373 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004374 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004375
4376 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004377 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4378 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4379 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004380 }
4381
4382 if (size != VK_WHOLE_SIZE) {
4383 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004384 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004385 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4386 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004387 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004388 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4389 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004390 }
4391 }
4392 return skip;
4393}
4394
sfricke-samsunga1d00272021-03-10 21:37:41 -08004395bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004396 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004397
4398 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004399 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4400 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4401 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4402 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004403 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004404 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4405 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4406 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004407 }
4408
4409 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4410 // queueFamilyIndexCount uint32_t values
4411 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004412 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004413 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004414 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004415 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4416 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004417 }
4418 }
4419
Dave Houlton413a6782018-05-22 13:01:54 -06004420 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004421 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004422
sfricke-samsunga1d00272021-03-10 21:37:41 -08004423 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4424 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4425 if (format_list_info) {
4426 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4427 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4428 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4429 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4430 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4431 func_name, viewFormatCount);
4432 }
4433
4434 // Using the first format, compare the rest of the formats against it that they are compatible
4435 for (uint32_t i = 1; i < viewFormatCount; i++) {
4436 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4437 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4438 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4439 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4440 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4441 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4442 string_VkFormat(format_list_info->pViewFormats[i]));
4443 }
4444 }
4445 }
4446
4447 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4448 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4449 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4450 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4451 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4452 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4453 func_name);
4454 } else {
4455 if (format_list_info == nullptr) {
4456 skip |= LogError(
4457 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4458 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4459 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4460 func_name);
4461 } else if (format_list_info->viewFormatCount == 0) {
4462 skip |= LogError(
4463 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4464 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4465 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4466 func_name);
4467 } else {
4468 bool found_base_format = false;
4469 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4470 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4471 found_base_format = true;
4472 break;
4473 }
4474 }
4475 if (!found_base_format) {
4476 skip |=
4477 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4478 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4479 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4480 "pCreateInfo->imageFormat.",
4481 func_name);
4482 }
4483 }
4484 }
4485 }
4486 }
4487 return skip;
4488}
4489
4490bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4491 const VkAllocationCallbacks *pAllocator,
4492 VkSwapchainKHR *pSwapchain) const {
4493 bool skip = false;
4494 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4495 return skip;
4496}
4497
4498bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4499 const VkSwapchainCreateInfoKHR *pCreateInfos,
4500 const VkAllocationCallbacks *pAllocator,
4501 VkSwapchainKHR *pSwapchains) const {
4502 bool skip = false;
4503 if (pCreateInfos) {
4504 for (uint32_t i = 0; i < swapchainCount; i++) {
4505 std::stringstream func_name;
4506 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4507 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4508 }
4509 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004510 return skip;
4511}
4512
Jeff Bolz5c801d12019-10-09 10:38:45 -05004513bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004514 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004515
4516 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004517 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004518 if (present_regions) {
4519 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004520 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004521 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4522 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004523 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004524 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4525 "extension swapchainCount is %i. These values must be equal.",
4526 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004527 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004528 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004529 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4530 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004531 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4532 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4533 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004534 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004535 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004536 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004537 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004538 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004539 }
4540 }
4541
4542 return skip;
4543}
4544
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004545bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4546 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4547 const VkAllocationCallbacks *pAllocator,
4548 VkDisplayModeKHR *pMode) const {
4549 bool skip = false;
4550
4551 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4552 if (display_mode_parameters.visibleRegion.width == 0) {
4553 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4554 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4555 }
4556 if (display_mode_parameters.visibleRegion.height == 0) {
4557 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4558 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4559 }
4560 if (display_mode_parameters.refreshRate == 0) {
4561 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4562 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4563 }
4564
4565 return skip;
4566}
4567
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004568#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004569bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4570 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4571 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004572 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004573 bool skip = false;
4574
4575 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004576 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4577 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004578 }
4579
4580 return skip;
4581}
4582#endif // VK_USE_PLATFORM_WIN32_KHR
4583
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004584bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004585 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004586 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004587 bool skip = false;
4588
4589 if (pCreateInfo) {
4590 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004591 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4592 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004593 }
4594
4595 if (pCreateInfo->pPoolSizes) {
4596 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4597 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004598 skip |= LogError(
4599 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004600 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004601 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004602 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4603 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004604 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4605 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4606 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4607 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4608 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004609 }
Petr Krausc8655be2017-09-27 18:56:51 +02004610 }
4611 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004612
4613 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4614 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4615 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4616 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4617 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4618 }
Petr Krausc8655be2017-09-27 18:56:51 +02004619 }
4620
4621 return skip;
4622}
4623
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004624bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004625 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004626 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004627
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004628 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004629 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004630 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4631 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4632 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004633 }
4634
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004635 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004636 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004637 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4638 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4639 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004640 }
4641
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004642 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004643 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004644 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4645 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4646 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004647 }
4648
4649 return skip;
4650}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004651
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004652bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004653 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004654 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004655
4656 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004657 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4658 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004659 }
4660 return skip;
4661}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004662
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004663bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4664 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004665 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004666 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004667
4668 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004669 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004670 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004671 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4672 "vkCmdDispatch(): baseGroupX (%" PRIu32
4673 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4674 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004675 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004676 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4677 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4678 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4679 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004680 }
4681
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004682 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004683 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004684 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4685 "vkCmdDispatch(): baseGroupY (%" PRIu32
4686 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4687 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004688 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004689 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4690 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4691 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4692 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004693 }
4694
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004695 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004696 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004697 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4698 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4699 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4700 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004701 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004702 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4703 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4704 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4705 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004706 }
4707
4708 return skip;
4709}
4710
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004711bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4712 VkPipelineBindPoint pipelineBindPoint,
4713 VkPipelineLayout layout, uint32_t set,
4714 uint32_t descriptorWriteCount,
4715 const VkWriteDescriptorSet *pDescriptorWrites) const {
4716 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4717}
4718
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004719bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4720 uint32_t firstExclusiveScissor,
4721 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004722 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004723 bool skip = false;
4724
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004725 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004726 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004727 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004728 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4729 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4730 ") is not 0.",
4731 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004732 }
4733 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004734 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004735 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4736 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4737 ") is not 1.",
4738 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004739 }
4740 } else { // multiViewport enabled
4741 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004742 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004743 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4744 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4745 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4746 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004747 }
4748 }
4749
Jeff Bolz3e71f782018-08-29 23:15:45 -05004750 if (pExclusiveScissors) {
4751 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4752 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4753
4754 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004755 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4756 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4757 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004758 }
4759
4760 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004761 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4762 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4763 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004764 }
4765
4766 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4767 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004768 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4769 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4770 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4771 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004772 }
4773
4774 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4775 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004776 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4777 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4778 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4779 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004780 }
4781 }
4782 }
4783
4784 return skip;
4785}
4786
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004787bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4788 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004789 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004790 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004791 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4792 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4793 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4794 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4795 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4796 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004797 }
4798
4799 return skip;
4800}
4801
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004802bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4803 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004804 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004805 bool skip = false;
4806
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004807 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004808 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004809 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004810 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4811 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4812 ") is not 0.",
4813 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004814 }
4815 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004816 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004817 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4818 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4819 ") is not 1.",
4820 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004821 }
4822 }
4823
Jeff Bolz9af91c52018-09-01 21:53:57 -05004824 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004825 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004826 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4827 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4828 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4829 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004830 }
4831
4832 return skip;
4833}
4834
Jeff Bolz5c801d12019-10-09 10:38:45 -05004835bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4836 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4837 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004838 bool skip = false;
4839
Dave Houlton142c4cb2018-10-17 15:04:41 -06004840 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004841 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4842 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4843 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004844 }
4845
4846 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004847 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004848 }
4849
4850 return skip;
4851}
4852
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004853bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004854 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004855 bool skip = false;
4856
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004857 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004858 skip |= LogError(
4859 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004860 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4861 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004862 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004863 }
4864
4865 return skip;
4866}
4867
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004868bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4869 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004870 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004871 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004872 static const int condition_multiples = 0b0011;
4873 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004874 skip |= LogError(
4875 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004876 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004877 }
Lockee1c22882019-06-10 16:02:54 -06004878 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004879 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4880 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4881 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4882 stride);
Lockee1c22882019-06-10 16:02:54 -06004883 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004884 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004885 skip |= LogError(
4886 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4887 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004888 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004889 if (drawCount > device_limits.maxDrawIndirectCount) {
4890 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004891 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4892 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004893 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004894 return skip;
4895}
4896
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004897bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4898 VkDeviceSize offset, VkBuffer countBuffer,
4899 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004900 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004901 bool skip = false;
4902
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004903 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004904 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4905 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4906 "), is not a multiple of 4.",
4907 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004908 }
4909
4910 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004911 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4912 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4913 "), is not a multiple of 4.",
4914 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004915 }
4916
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004917 return skip;
4918}
4919
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004920bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004921 const VkAllocationCallbacks *pAllocator,
4922 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004923 bool skip = false;
4924
4925 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4926 if (pCreateInfo != nullptr) {
4927 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4928 // VkQueryPipelineStatisticFlagBits values
4929 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4930 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004931 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4932 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4933 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4934 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004935 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004936 if (pCreateInfo->queryCount == 0) {
4937 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4938 "vkCreateQueryPool(): queryCount must be greater than zero.");
4939 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004940 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004941 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004942}
4943
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004944bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4945 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004946 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004947 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4948 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004949}
4950
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004951void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004952 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4953 VkResult result) {
4954 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004955 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004956}
4957
Mike Schuchardt2df08912020-12-15 16:28:09 -08004958void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004959 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4960 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004961 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004962 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004963 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004964}
4965
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004966void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4967 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004968 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004969 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004970 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004971}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004972
Tony-LunarG3c287f62020-12-17 12:39:49 -07004973void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004974 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004975 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4976 auto lock = cb_write_lock();
4977 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004978 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004979 }
4980 }
4981}
4982
4983void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004984 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004985 auto lock = cb_write_lock();
4986 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4987 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4988 }
4989}
4990
4991void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004992 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004993 auto lock = cb_write_lock();
4994 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4995 if (item->second == commandPool) {
4996 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004997 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004998 ++item;
4999 }
5000 }
5001}
5002
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005003bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005004 const VkAllocationCallbacks *pAllocator,
5005 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005006 bool skip = false;
5007
5008 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005009 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005010 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005011 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5012 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005013 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005014
5015 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005016 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005017 if (flags_info) {
5018 flags = flags_info->flags;
5019 }
5020
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005021 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005022 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005023 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005024 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5025 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005026 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005027 }
5028
5029#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005030 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005031#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005032 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5033 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005034#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005035 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005036#endif
5037
5038 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005039 skip |= LogError(
5040 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005041 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5042 }
5043 if (
5044#ifdef VK_USE_PLATFORM_WIN32_KHR
5045 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5046#endif
5047 (import_memory_fd && import_memory_fd->handleType) ||
5048#ifdef VK_USE_PLATFORM_ANDROID_KHR
5049 (import_memory_ahb && import_memory_ahb->buffer) ||
5050#endif
5051 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005052 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5053 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005054 }
5055 }
5056
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005057 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5058 if (export_memory) {
5059 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5060 if (export_memory_nv) {
5061 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5062 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5063 "VkExportMemoryAllocateInfoNV");
5064 }
5065#ifdef VK_USE_PLATFORM_WIN32_KHR
5066 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5067 if (export_memory_win32_nv) {
5068 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5069 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5070 "VkExportMemoryWin32HandleInfoNV");
5071 }
5072#endif
5073 }
5074
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005075 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005076 VkBool32 capture_replay = false;
5077 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005078 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005079 if (vulkan_12_features) {
5080 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5081 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5082 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005083 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005084 if (bda_features) {
5085 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5086 buffer_device_address = bda_features->bufferDeviceAddress;
5087 }
5088 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005089 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005090 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005091 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005092 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005093 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005094 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005095 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005096 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005097 }
5098 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005099 }
5100 return skip;
5101}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005102
Jason Macnak192fa0e2019-07-26 15:07:16 -07005103bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005104 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005105 bool skip = false;
5106
5107 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5108 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5109 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005110 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005111 } else {
5112 uint32_t vertex_component_size = 0;
5113 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5114 vertex_component_size = 4;
5115 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5116 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5117 vertex_component_size = 2;
5118 }
5119 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005120 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005121 }
5122 }
5123
5124 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5125 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005126 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005127 } else {
5128 uint32_t index_element_size = 0;
5129 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5130 index_element_size = 4;
5131 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5132 index_element_size = 2;
5133 }
5134 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005135 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005136 }
5137 }
5138 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5139 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005140 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005141 }
5142 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005143 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005144 }
5145 }
5146
5147 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005148 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005149 }
5150
5151 return skip;
5152}
5153
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005154bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5155 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005156 bool skip = false;
5157
5158 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005159 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005160 }
5161 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005162 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005163 }
5164
5165 return skip;
5166}
5167
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005168bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5169 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005170 bool skip = false;
5171 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005172 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005173 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005174 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005175 }
5176 return skip;
5177}
5178
5179bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005180 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005181 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005182 bool skip = false;
5183 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005184 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5185 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5186 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005187 }
5188 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005189 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5190 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5191 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005192 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005193 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5194 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5195 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5196 }
Jason Macnak5c954952019-07-09 15:46:12 -07005197 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5198 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005199 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5200 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5201 "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 -07005202 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005203 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005204 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005205 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5206 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005207 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5208 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005209 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005210 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005211 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5212 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5213 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005214 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005215 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005216 uint64_t total_triangle_count = 0;
5217 for (uint32_t i = 0; i < info.geometryCount; i++) {
5218 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005219
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005220 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005221
Jason Macnak5c954952019-07-09 15:46:12 -07005222 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5223 continue;
5224 }
5225 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5226 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005227 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005228 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5229 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5230 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005231 }
5232 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005233 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5234 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5235 for (uint32_t i = 1; i < info.geometryCount; i++) {
5236 const VkGeometryNV &geometry = info.pGeometries[i];
5237 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005238 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005239 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
5240 "info.pGeometries[0].geometryType.",
5241 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005242 }
5243 }
5244 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005245 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5246 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5247 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5248 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5249 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5250 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5251 }
5252 }
5253 skip |=
5254 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005255 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005256 return skip;
5257}
5258
Ricardo Garciaa4935972019-02-21 17:43:18 +01005259bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5260 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005261 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005262 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005263 if (pCreateInfo) {
5264 if ((pCreateInfo->compactedSize != 0) &&
5265 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005266 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5267 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5268 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5269 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005270 }
Jason Macnak5c954952019-07-09 15:46:12 -07005271
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005272 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005273 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005274 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005275 return skip;
5276}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005277
Jeff Bolz5c801d12019-10-09 10:38:45 -05005278bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5279 const VkAccelerationStructureInfoNV *pInfo,
5280 VkBuffer instanceData, VkDeviceSize instanceOffset,
5281 VkBool32 update, VkAccelerationStructureNV dst,
5282 VkAccelerationStructureNV src, VkBuffer scratch,
5283 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005284 bool skip = false;
5285
5286 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005287 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005288 }
5289
5290 return skip;
5291}
5292
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005293bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5294 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5295 VkAccelerationStructureKHR *pAccelerationStructure) const {
5296 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005297 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005298 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005299 if (!acceleration_structure_features ||
5300 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5301 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5302 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5303 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005304 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005305 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5306 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005307 (acceleration_structure_features &&
5308 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005309 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005310 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5311 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5312 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5313 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005314 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005315 if (pCreateInfo->deviceAddress &&
5316 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5317 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5318 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5319 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5320 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005321 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5322 (acceleration_structure_features &&
5323 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5324 skip |= LogError(
5325 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5326 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5327 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5328 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005329 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5330 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005331 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5332 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005333 }
sourav parmar83c31b12020-05-06 12:30:54 -07005334 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005335 return skip;
5336}
5337
Jason Macnak5c954952019-07-09 15:46:12 -07005338bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5339 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005340 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005341 bool skip = false;
5342 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005343 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5344 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005345 }
5346 return skip;
5347}
5348
sourav parmarcd5fb182020-07-17 12:58:44 -07005349bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5350 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5351 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5352 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005353 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005354 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005355 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005356 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005357 }
5358 return skip;
5359}
5360
Peter Chen85366392019-05-14 15:20:11 -04005361bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5362 uint32_t createInfoCount,
5363 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5364 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005365 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005366 bool skip = false;
5367
5368 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005369 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5370 std::stringstream msg;
5371 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5372 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5373 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005374 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005375 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005376 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005377 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5378 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5379 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5380 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005381 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005382
5383 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005384 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005385 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5386 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5387 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5388 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5389 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5390 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5391 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5392 }
5393 }
5394
sourav parmarf4a78252020-04-10 13:04:21 -07005395 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5396 skip |=
5397 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5398 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5399 }
5400 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5401 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5402 skip |=
5403 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5404 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5405 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5406 }
5407 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5408 if (pCreateInfos[i].basePipelineIndex != -1) {
5409 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5410 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5411 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5412 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5413 "and pCreateInfos->basePipelineIndex is not -1.");
5414 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005415 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005416 skip |=
5417 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5418 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5419 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5420 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5421 "that element.");
5422 }
sourav parmarf4a78252020-04-10 13:04:21 -07005423 }
5424 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005425 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005426 skip |=
5427 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5428 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5429 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5430 "commands pCreateInfos parameter.");
5431 }
5432 } else {
5433 if (pCreateInfos[i].basePipelineIndex != -1) {
5434 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5435 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5436 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5437 }
5438 }
5439 }
5440 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5441 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5442 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5443 }
5444 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5445 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5446 "vkCreateRayTracingPipelinesNV: flags must not include "
5447 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5448 }
5449 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5450 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5451 "vkCreateRayTracingPipelinesNV: flags must not include "
5452 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5453 }
5454 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5455 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5456 "vkCreateRayTracingPipelinesNV: flags must not include "
5457 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5458 }
5459 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5460 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5461 "vkCreateRayTracingPipelinesNV: flags must not include "
5462 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5463 }
5464 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5465 skip |= LogError(
5466 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5467 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5468 }
5469 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5470 skip |= LogError(
5471 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5472 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5473 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005474 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5475 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5476 "vkCreateRayTracingPipelinesNV: flags must not include "
5477 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5478 }
5479 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5480 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5481 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5482 }
Peter Chen85366392019-05-14 15:20:11 -04005483 }
5484
5485 return skip;
5486}
5487
sourav parmarcd5fb182020-07-17 12:58:44 -07005488bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5489 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5490 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005491 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005492 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005493 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5494 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5495 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005496 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005497 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005498 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5499 std::stringstream msg;
5500 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5501 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5502 &pCreateInfos[i].pStages[i]);
5503 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005504 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5505 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5506 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5507 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5508 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5509 }
5510 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5511 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5512 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5513 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5514 }
5515 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005516 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005517 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5518 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005519 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5520 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5521 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005522 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5523 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5524 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005525 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005526 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005527 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5528 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5529 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5530 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005531 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005532 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5533 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5534 }
5535 }
sourav parmarf4a78252020-04-10 13:04:21 -07005536 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005537 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5538 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005539 }
5540 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005541 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005542 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005543 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5544 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005545 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005546 }
5547 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5548 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5549 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005550 }
5551 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5552 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5553 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5554 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5555 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5556 skip |= LogError(
5557 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005558 "vkCreateRayTracingPipelinesKHR: If flags includes "
5559 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005560 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5561 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5562 "must not be VK_SHADER_UNUSED_KHR");
5563 }
5564 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5565 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5566 skip |= LogError(
5567 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005568 "vkCreateRayTracingPipelinesKHR: If flags includes "
5569 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005570 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5571 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5572 "element must not be VK_SHADER_UNUSED_KHR");
5573 }
5574 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005575 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5576 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5577 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5578 skip |= LogError(
5579 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5580 "vkCreateRayTracingPipelinesKHR: If "
5581 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5582 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5583 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5584 }
5585 }
sourav parmarf4a78252020-04-10 13:04:21 -07005586 }
5587 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5588 if (pCreateInfos[i].basePipelineIndex != -1) {
5589 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5590 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005591 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005592 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5593 "and pCreateInfos->basePipelineIndex is not -1.");
5594 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005595 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005596 skip |=
5597 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5598 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5599 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5600 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5601 "element.");
5602 }
sourav parmarf4a78252020-04-10 13:04:21 -07005603 }
5604 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005605 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005606 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005607 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005608 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5609 "commands pCreateInfos parameter %d.",
5610 pCreateInfos[i].basePipelineIndex, createInfoCount);
5611 }
5612 } else {
5613 if (pCreateInfos[i].basePipelineIndex != -1) {
5614 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005615 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005616 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5617 }
5618 }
5619 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005620 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5621 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5622 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5623 "vkCreateRayTracingPipelinesKHR: If flags includes "
5624 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5625 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005626 }
5627 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5628 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5629 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5630 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5631 "pLibraryInfo and pLibraryInterface must be NULL.");
5632 }
5633 if (pCreateInfos[i].pLibraryInfo) {
5634 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5635 if (pCreateInfos[i].stageCount == 0) {
5636 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5637 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5638 "stageCount must not be 0.");
5639 }
5640 if (pCreateInfos[i].groupCount == 0) {
5641 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5642 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5643 "groupCount must not be 0.");
5644 }
5645 } else {
5646 if (pCreateInfos[i].pLibraryInterface == NULL) {
5647 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5648 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5649 "is greater than 0, its "
5650 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005651 }
5652 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005653 }
5654 if (pCreateInfos[i].pLibraryInterface) {
5655 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5656 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5657 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5658 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5659 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5660 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005661 }
5662 if (deferredOperation != VK_NULL_HANDLE) {
5663 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5664 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5665 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5666 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005667 }
5668 }
ziga-lunargdea76582021-09-17 14:38:08 +02005669 if (pCreateInfos[i].pDynamicState) {
5670 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
5671 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
5672 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
5673 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
5674 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
5675 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
5676 }
5677 }
5678 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005679 }
5680
5681 return skip;
5682}
5683
Mike Schuchardt21638df2019-03-16 10:52:02 -07005684#ifdef VK_USE_PLATFORM_WIN32_KHR
5685bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5686 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005687 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005688 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07005689 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005690 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005691 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005692 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005693 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005694 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005695 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005696 skip |=
5697 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005698 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005699 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5700 skip |= validate_struct_type(
5701 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5702 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5703 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5704 if (pSurfaceInfo != NULL) {
5705 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5706 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5707 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5708
5709 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5710 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5711 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5712 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005713 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5714 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005715
5716 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5717 }
5718 return skip;
5719}
5720#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005721
5722bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5723 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005724 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005725 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5726 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005727 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005728 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5729 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5730 }
5731 return skip;
5732}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005733
5734bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005735 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005736 bool skip = false;
5737
5738 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005739 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5740 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005741 }
5742
5743 return skip;
5744}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005745
5746bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005747 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005748 bool skip = false;
5749
5750 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005751 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5752 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005753 }
5754
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005755 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005756 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005757 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5758 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005759 }
5760
5761 return skip;
5762}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005763
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005764bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5765 uint32_t bindingCount, const VkBuffer *pBuffers,
5766 const VkDeviceSize *pOffsets) const {
5767 bool skip = false;
5768 if (firstBinding > device_limits.maxVertexInputBindings) {
5769 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5770 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5771 device_limits.maxVertexInputBindings);
5772 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5773 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5774 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5775 "maxVertexInputBindings (%u)",
5776 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5777 }
5778
Jeff Bolz165818a2020-05-08 11:19:03 -05005779 for (uint32_t i = 0; i < bindingCount; ++i) {
5780 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005781 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005782 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5783 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5784 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5785 } else {
5786 if (pOffsets[i] != 0) {
5787 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5788 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5789 }
5790 }
5791 }
5792 }
5793
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005794 return skip;
5795}
5796
Mark Lobodzinski84988402019-09-11 15:27:30 -06005797bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005798 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005799 bool skip = false;
5800 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005801 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5802 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005803 }
5804 return skip;
5805}
5806
5807bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005808 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005809 bool skip = false;
5810 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005811 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5812 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005813 }
5814 return skip;
5815}
Petr Kraus3d720392019-11-13 02:52:39 +01005816
5817bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5818 VkSemaphore semaphore, VkFence fence,
5819 uint32_t *pImageIndex) const {
5820 bool skip = false;
5821
5822 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005823 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5824 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005825 }
5826
5827 return skip;
5828}
5829
5830bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5831 uint32_t *pImageIndex) const {
5832 bool skip = false;
5833
5834 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005835 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5836 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005837 }
5838
5839 return skip;
5840}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005841
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005842bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5843 uint32_t firstBinding, uint32_t bindingCount,
5844 const VkBuffer *pBuffers,
5845 const VkDeviceSize *pOffsets,
5846 const VkDeviceSize *pSizes) const {
5847 bool skip = false;
5848
5849 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5850 for (uint32_t i = 0; i < bindingCount; ++i) {
5851 if (pOffsets[i] & 3) {
5852 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5853 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5854 }
5855 }
5856
5857 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5858 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5859 "%s: The firstBinding(%" PRIu32
5860 ") index is greater than or equal to "
5861 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5862 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5863 }
5864
5865 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5866 skip |=
5867 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5868 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5869 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5870 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5871 }
5872
5873 for (uint32_t i = 0; i < bindingCount; ++i) {
5874 // pSizes is optional and may be nullptr.
5875 if (pSizes != nullptr) {
5876 if (pSizes[i] != VK_WHOLE_SIZE &&
5877 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5878 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5879 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5880 ") is not VK_WHOLE_SIZE and is greater than "
5881 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5882 cmd_name, i, pSizes[i]);
5883 }
5884 }
5885 }
5886
5887 return skip;
5888}
5889
5890bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5891 uint32_t firstCounterBuffer,
5892 uint32_t counterBufferCount,
5893 const VkBuffer *pCounterBuffers,
5894 const VkDeviceSize *pCounterBufferOffsets) const {
5895 bool skip = false;
5896
5897 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5898 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5899 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5900 "%s: The firstCounterBuffer(%" PRIu32
5901 ") index is greater than or equal to "
5902 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5903 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5904 }
5905
5906 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5907 skip |=
5908 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5909 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5910 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5911 cmd_name, firstCounterBuffer, counterBufferCount,
5912 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5913 }
5914
5915 return skip;
5916}
5917
5918bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5919 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5920 const VkBuffer *pCounterBuffers,
5921 const VkDeviceSize *pCounterBufferOffsets) const {
5922 bool skip = false;
5923
5924 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5925 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5926 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5927 "%s: The firstCounterBuffer(%" PRIu32
5928 ") index is greater than or equal to "
5929 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5930 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5931 }
5932
5933 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5934 skip |=
5935 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5936 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5937 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5938 cmd_name, firstCounterBuffer, counterBufferCount,
5939 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5940 }
5941
5942 return skip;
5943}
5944
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005945bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5946 uint32_t firstInstance, VkBuffer counterBuffer,
5947 VkDeviceSize counterBufferOffset,
5948 uint32_t counterOffset, uint32_t vertexStride) const {
5949 bool skip = false;
5950
5951 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005952 skip |= LogError(
5953 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005954 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5955 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5956 }
5957
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005958 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005959 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005960 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005961 }
5962
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005963 return skip;
5964}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005965
5966bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5967 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5968 const VkAllocationCallbacks *pAllocator,
5969 VkSamplerYcbcrConversion *pYcbcrConversion,
5970 const char *apiName) const {
5971 bool skip = false;
5972
5973 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005974 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005975 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005976 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005977 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5978 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005979 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005980 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005981 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005982
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005983#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005984 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005985 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005986#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005987 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005988#endif
5989
sfricke-samsung1a72f942020-07-25 12:09:18 -07005990 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005991
5992 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005993 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005994 const VkComponentMapping components = pCreateInfo->components;
5995 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5996 if (FormatIsXChromaSubsampled(format) == true) {
5997 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5998 skip |=
5999 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006000 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6001 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006002 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006003 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006004
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006005 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6006 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6007 skip |= LogError(
6008 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6009 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6010 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6011 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6012 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006013
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006014 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6015 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6016 skip |=
6017 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006018 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6019 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006020 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006021 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006022
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006023 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6024 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6025 skip |=
6026 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006027 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6028 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006029 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006030 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006031
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006032 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006033 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6034 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6035 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006036 skip |=
6037 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006038 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6039 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006040 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6041 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006042 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006043 }
6044
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006045 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6046 // Checks same VU multiple ways in order to give a more useful error message
6047 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6048 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6049 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6050 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6051 skip |= LogError(
6052 device, vuid,
6053 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6054 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6055 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6056 string_VkComponentSwizzle(components.b));
6057 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006058
sfricke-samsunged028b02021-09-06 23:14:51 -07006059 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6060 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006061 // 3 = no [a]
6062 // 2 = no [b,a]
6063 // 1 = no [g,b,a]
6064 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006065 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006066
sfricke-samsunged028b02021-09-06 23:14:51 -07006067 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6068 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006069 skip |= LogError(device, vuid,
6070 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6071 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6072 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6073 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006074 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006075 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6076 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6077 skip |= LogError(device, vuid,
6078 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6079 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6080 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6081 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6082 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006083 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006084 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6085 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6086 skip |= LogError(device, vuid,
6087 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6088 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6089 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6090 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6091 string_VkComponentSwizzle(components.b));
6092 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006093 }
6094 }
6095
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006096 return skip;
6097}
6098
6099bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6100 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6101 const VkAllocationCallbacks *pAllocator,
6102 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6103 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6104 "vkCreateSamplerYcbcrConversion");
6105}
6106
6107bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6108 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6109 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6110 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6111 "vkCreateSamplerYcbcrConversionKHR");
6112}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006113
6114bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6115 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6116 bool skip = false;
6117 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6118 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6119
6120 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006121 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6122 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6123 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6124 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6125 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006126 }
6127 return skip;
6128}
sourav parmara96ab1a2020-04-25 16:28:23 -07006129
6130bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006131 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006132 bool skip = false;
6133 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6134 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6135 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6136 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006137 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006138 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6139 skip |= LogError(
6140 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6141 "vkCopyAccelerationStructureToMemoryKHR: The "
6142 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6143 }
6144 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6145 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6146 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6147 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6148 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6149 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006150 return skip;
6151}
6152
6153bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6154 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6155 bool skip = false;
6156 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6157 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6158 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6159 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6160 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006161 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6162 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006163 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006164 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006165 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006166 return skip;
6167}
6168
6169bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6170 const char *api_name) const {
6171 bool skip = false;
6172 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6173 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6174 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6175 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6176 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6177 api_name);
6178 }
6179 return skip;
6180}
6181
6182bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006183 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006184 bool skip = false;
6185 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006186 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006187 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006188 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006189 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6190 "vkCopyAccelerationStructureKHR: The "
6191 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006192 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006193 return skip;
6194}
6195
6196bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6197 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6198 bool skip = false;
6199 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6200 return skip;
6201}
6202
6203bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006204 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006205 bool skip = false;
6206 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006207 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006208 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6209 }
6210 return skip;
6211}
6212
6213bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006214 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006215 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006216 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006217 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006218 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6219 skip |= LogError(
6220 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6221 "vkCopyMemoryToAccelerationStructureKHR: The "
6222 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006223 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006224 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6225 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006226 return skip;
6227}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006228
sourav parmara96ab1a2020-04-25 16:28:23 -07006229bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6230 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6231 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006232 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006233 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6234 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006235 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006236 pInfo->src.deviceAddress);
6237 }
sourav parmar83c31b12020-05-06 12:30:54 -07006238 return skip;
6239}
6240bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6241 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6242 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6243 bool skip = false;
6244 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6245 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6246 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6247 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6248 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6249 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6250 }
6251 return skip;
6252}
6253bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6254 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6255 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6256 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006257 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006258 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6259 skip |= LogError(
6260 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6261 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6262 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6263 }
sourav parmar83c31b12020-05-06 12:30:54 -07006264 if (dataSize < accelerationStructureCount * stride) {
6265 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6266 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
6267 "accelerationStructureCount (%d) *stride(%zu).",
6268 dataSize, accelerationStructureCount, stride);
6269 }
6270 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6271 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6272 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6273 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6274 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6275 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6276 }
6277 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6278 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6279 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6280 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6281 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6282 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6283 stride);
6284 }
6285 }
6286 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6287 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6288 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6289 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6290 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6291 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6292 stride);
6293 }
6294 }
sourav parmar83c31b12020-05-06 12:30:54 -07006295 return skip;
6296}
6297bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6298 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6299 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006300 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006301 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6302 skip |= LogError(
6303 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6304 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6305 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006306 }
6307 return skip;
6308}
6309
6310bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006311 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6312 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6313 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6314 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006315 uint32_t width, uint32_t height, uint32_t depth) const {
6316 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006317 // RayGen
6318 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6319 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6320 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006321 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006322 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6323 0) {
6324 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6325 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6326 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6327 }
6328 // Callable
6329 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6330 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6331 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6332 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006333 }
6334 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6335 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6336 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006337 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6338 }
6339 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6340 0) {
6341 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6342 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6343 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006344 }
6345 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006346 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6347 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6348 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6349 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006350 }
6351 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6352 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006353 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6354 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006355 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006356 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6357 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6358 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6359 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6360 }
sourav parmar83c31b12020-05-06 12:30:54 -07006361 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006362 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6363 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6364 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6365 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006366 }
6367 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6368 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6369 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006370 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6371 }
6372 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6373 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6374 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6375 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6376 }
6377 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6378 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6379 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6380 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6381 }
6382 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6383 skip |=
6384 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6385 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6386 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006387 }
6388
sourav parmarcd5fb182020-07-17 12:58:44 -07006389 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6390 skip |=
6391 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6392 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6393 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6394 }
6395
6396 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6397 skip |=
6398 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6399 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6400 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006401 }
6402 return skip;
6403}
6404
sourav parmarcd5fb182020-07-17 12:58:44 -07006405bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6406 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6407 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6408 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006409 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006410 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006411 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6412 skip |= LogError(
6413 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6414 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6415 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006416 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006417 // RayGen
6418 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6419 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6420 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006421 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006422 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6423 0) {
6424 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6425 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6426 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6427 }
6428 // Callabe
6429 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6430 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6431 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6432 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006433 }
6434 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6435 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006436 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6437 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6438 }
6439 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6440 0) {
6441 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6442 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6443 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006444 }
6445 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006446 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6447 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6448 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6449 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006450 }
6451 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6452 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006453 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6454 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006455 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006456 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6457 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6458 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6459 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6460 }
sourav parmar83c31b12020-05-06 12:30:54 -07006461 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006462 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6463 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6464 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6465 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006466 }
6467 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6468 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006469 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6470 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6471 }
6472 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6473 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6474 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6475 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006476 }
6477
sourav parmarcd5fb182020-07-17 12:58:44 -07006478 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6479 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6480 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006481 }
6482 return skip;
6483}
6484bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6485 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6486 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6487 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6488 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6489 uint32_t width, uint32_t height, uint32_t depth) const {
6490 bool skip = false;
6491 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6492 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6493 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6494 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6495 }
6496 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6497 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6498 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6499 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6500 }
6501 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6502 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6503 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6504 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6505 }
6506
6507 // hitShader
6508 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6509 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6510 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6511 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6512 }
6513 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6514 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6515 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6516 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6517 }
6518 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6519 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6520 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6521 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6522 }
6523
6524 // missShader
6525 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6526 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6527 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6528 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6529 }
6530 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6531 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6532 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6533 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6534 }
6535 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6536 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6537 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6538 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6539 }
6540
6541 // raygenShader
6542 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6543 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6544 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006545 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6546 }
6547 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6548 skip |=
6549 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6550 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6551 }
6552 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6553 skip |=
6554 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6555 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6556 }
6557 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6558 skip |=
6559 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6560 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006561 }
6562 return skip;
6563}
6564
sourav parmar83c31b12020-05-06 12:30:54 -07006565bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006566 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6567 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006568 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006569 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6570 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006571 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6572 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006573 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006574 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6575 }
6576 return skip;
6577}
6578
Piers Daniell39842ee2020-07-10 16:42:33 -06006579bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6580 const VkViewport *pViewports) const {
6581 bool skip = false;
6582
6583 if (!physical_device_features.multiViewport) {
6584 if (viewportCount != 1) {
6585 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6586 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6587 ") is not 1.",
6588 viewportCount);
6589 }
6590 } else { // multiViewport enabled
6591 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6592 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6593 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6594 ") must "
6595 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6596 viewportCount, device_limits.maxViewports);
6597 }
6598 }
6599
6600 if (pViewports) {
6601 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6602 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6603 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6604 skip |= manual_PreCallValidateViewport(
6605 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6606 }
6607 }
6608
6609 return skip;
6610}
6611
6612bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6613 const VkRect2D *pScissors) const {
6614 bool skip = false;
6615
6616 if (!physical_device_features.multiViewport) {
6617 if (scissorCount != 1) {
6618 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6619 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6620 ") must "
6621 "be 1 when the multiViewport feature is disabled.",
6622 scissorCount);
6623 }
6624 } else { // multiViewport enabled
6625 if (scissorCount == 0) {
6626 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6627 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6628 ") must "
6629 "be great than zero.",
6630 scissorCount);
6631 } else if (scissorCount > device_limits.maxViewports) {
6632 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6633 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6634 ") must "
6635 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6636 scissorCount, device_limits.maxViewports);
6637 }
6638 }
6639
6640 if (pScissors) {
6641 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6642 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6643
6644 if (scissor.offset.x < 0) {
6645 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6646 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6647 scissor.offset.x);
6648 }
6649
6650 if (scissor.offset.y < 0) {
6651 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6652 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6653 scissor.offset.y);
6654 }
6655
6656 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6657 if (x_sum > INT32_MAX) {
6658 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6659 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6660 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6661 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6662 }
6663
6664 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6665 if (y_sum > INT32_MAX) {
6666 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6667 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6668 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6669 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6670 }
6671 }
6672 }
6673
6674 return skip;
6675}
6676
6677bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6678 uint32_t bindingCount, const VkBuffer *pBuffers,
6679 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6680 const VkDeviceSize *pStrides) const {
6681 bool skip = false;
6682 if (firstBinding >= device_limits.maxVertexInputBindings) {
6683 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6684 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6685 firstBinding, device_limits.maxVertexInputBindings);
6686 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6687 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6688 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6689 "maxVertexInputBindings (%u)",
6690 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6691 }
6692
6693 for (uint32_t i = 0; i < bindingCount; ++i) {
6694 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006695 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006696 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6697 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6698 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6699 } else {
6700 if (pOffsets[i] != 0) {
6701 skip |=
6702 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6703 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6704 }
6705 }
6706 }
6707 if (pStrides) {
6708 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6709 skip |=
6710 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006711 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i,
Piers Daniell39842ee2020-07-10 16:42:33 -06006712 pStrides[i], device_limits.maxVertexInputBindingStride);
6713 }
6714 }
6715 }
6716
6717 return skip;
6718}
sourav parmarcd5fb182020-07-17 12:58:44 -07006719
6720bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6721 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6722 bool skip = false;
6723 for (uint32_t i = 0; i < infoCount; ++i) {
6724 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6725 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6726 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6727 }
6728 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6729 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6730 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6731 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6732 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6733 api_name);
6734 }
6735 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6736 skip |=
6737 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6738 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6739 }
6740 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6741 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6742 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6743 }
6744 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6745 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6746 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6747 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6748 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6749 api_name);
6750 }
6751 if (pInfos[i].pGeometries) {
6752 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6753 skip |= validate_ranged_enum(
6754 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6755 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6756 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6757 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006758 skip |= validate_struct_type(
6759 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6760 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6761 &(pInfos[i].pGeometries[j].geometry.triangles),
6762 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6763 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6764 skip |= validate_struct_pnext(
6765 api_name,
6766 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6767 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6768 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6769 skip |=
6770 validate_ranged_enum(api_name,
6771 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6772 ParameterName::IndexVector{i, j}),
6773 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6774 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6775 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6776 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6777 &pInfos[i].pGeometries[j].geometry.triangles,
6778 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6779 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6780 skip |= validate_ranged_enum(
6781 api_name,
6782 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6783 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6784 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6785
6786 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6787 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6788 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6789 }
6790 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6791 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6792 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6793 skip |=
6794 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6795 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6796 api_name);
6797 }
6798 }
6799 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6800 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6801 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6802 &pInfos[i].pGeometries[j].geometry.instances,
6803 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6804 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6805 skip |= validate_struct_type(
6806 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6807 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6808 &(pInfos[i].pGeometries[j].geometry.instances),
6809 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6810 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6811 skip |= validate_struct_pnext(
6812 api_name,
6813 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6814 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6815 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6816
6817 skip |= validate_bool32(api_name,
6818 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6819 ParameterName::IndexVector{i, j}),
6820 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6821 }
6822 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6823 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6824 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6825 &pInfos[i].pGeometries[j].geometry.aabbs,
6826 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6827 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6828 skip |= validate_struct_type(
6829 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6830 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6831 &(pInfos[i].pGeometries[j].geometry.aabbs),
6832 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6833 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6834 skip |= validate_struct_pnext(
6835 api_name,
6836 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6837 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6838 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6839 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6840 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6841 "(%s):stride must be less than or equal to 2^32-1", api_name);
6842 }
6843 }
6844 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6845 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6846 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6847 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6848 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6849 api_name);
6850 }
6851 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6852 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6853 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6854 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6855 "of elements of"
6856 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6857 api_name);
6858 }
6859 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6860 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6861 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6862 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6863 api_name);
6864 }
6865 }
6866 }
6867 }
6868 if (pInfos[i].ppGeometries != NULL) {
6869 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6870 skip |= validate_ranged_enum(
6871 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6872 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6873 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6874 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006875 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6876 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6877 &pInfos[i].ppGeometries[j]->geometry.triangles,
6878 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6879 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6880 skip |= validate_struct_type(
6881 api_name,
6882 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6883 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6884 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6885 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6886 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6887 skip |= validate_struct_pnext(
6888 api_name,
6889 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6890 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6891 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6892 skip |= validate_ranged_enum(api_name,
6893 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6894 ParameterName::IndexVector{i, j}),
6895 "VkFormat", AllVkFormatEnums,
6896 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6897 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6898 skip |= validate_ranged_enum(api_name,
6899 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6900 ParameterName::IndexVector{i, j}),
6901 "VkIndexType", AllVkIndexTypeEnums,
6902 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6903 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6904 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6905 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6906 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6907 }
6908 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6909 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6910 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6911 skip |=
6912 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6913 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6914 api_name);
6915 }
6916 }
6917 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6918 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6919 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6920 &pInfos[i].ppGeometries[j]->geometry.instances,
6921 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6922 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6923 skip |= validate_struct_type(
6924 api_name,
6925 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6926 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6927 &(pInfos[i].ppGeometries[j]->geometry.instances),
6928 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6929 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6930 skip |= validate_struct_pnext(
6931 api_name,
6932 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6933 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6934 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6935 skip |= validate_bool32(api_name,
6936 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6937 ParameterName::IndexVector{i, j}),
6938 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6939 }
6940 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6941 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6942 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6943 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6944 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6945 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6946 skip |= validate_struct_type(
6947 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6948 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6949 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6950 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6951 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6952 skip |= validate_struct_pnext(
6953 api_name,
6954 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6955 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6956 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6957 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6958 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6959 "(%s):stride must be less than or equal to 2^32-1", api_name);
6960 }
6961 }
6962 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6963 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6964 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6965 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6966 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6967 api_name);
6968 }
6969 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6970 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6971 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6972 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6973 "of elements of"
6974 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6975 api_name);
6976 }
6977 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6978 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6979 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6980 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6981 api_name);
6982 }
6983 }
6984 }
6985 }
6986 }
6987 return skip;
6988}
6989bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6990 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6991 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6992 bool skip = false;
6993 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6994 for (uint32_t i = 0; i < infoCount; ++i) {
6995 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6996 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6997 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6998 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6999 "scratchData.deviceAddress member must be a multiple of "
7000 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7001 }
7002 for (uint32_t k = 0; k < infoCount; ++k) {
7003 if (i == k) continue;
7004 bool found = false;
7005 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
7006 skip |= LogError(
7007 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7008 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
7009 "not be "
7010 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7011 i, k);
7012 found = true;
7013 }
7014 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
7015 skip |= LogError(
7016 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7017 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
7018 "not be "
7019 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7020 i, k);
7021 found = true;
7022 }
7023 if (found) break;
7024 }
7025 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7026 if (pInfos[i].pGeometries) {
7027 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7028 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7029 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7030 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7031 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7032 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7033 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7034 }
7035 } else {
7036 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7037 skip |=
7038 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7039 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7040 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7041 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7042 }
7043 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007044 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007045 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7046 skip |= LogError(
7047 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7048 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7049 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7050 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007051 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7052 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007053 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7054 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7055 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7056 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7057 }
7058 }
7059 } else if (pInfos[i].ppGeometries) {
7060 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7061 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7062 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7063 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7064 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7065 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7066 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7067 }
7068 } else {
7069 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7070 skip |=
7071 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7072 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7073 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7074 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7075 }
7076 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007077 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007078 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7079 skip |= LogError(
7080 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7081 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7082 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7083 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007084 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7085 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007086 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7087 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7088 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7089 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7090 }
7091 }
7092 }
7093 }
7094 }
7095 return skip;
7096}
7097
7098bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7099 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7100 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7101 const uint32_t *const *ppMaxPrimitiveCounts) const {
7102 bool skip = false;
7103 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7104 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007105 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007106 if (!ray_tracing_acceleration_structure_features ||
7107 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7108 skip |= LogError(
7109 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7110 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7111 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7112 }
7113 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007114 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7115 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7116 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7117 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7118 "scratchData.deviceAddress member must be a multiple of "
7119 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7120 }
7121 for (uint32_t k = 0; k < infoCount; ++k) {
7122 if (i == k) continue;
7123 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
7124 skip |=
7125 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7126 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
7127 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7128 "any other element [%d) of pInfos.",
7129 i, k);
7130 break;
7131 }
7132 }
7133 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7134 if (pInfos[i].pGeometries) {
7135 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7136 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7137 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7138 skip |= LogError(
7139 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7140 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7141 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7142 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7143 }
7144 } else {
7145 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7146 skip |= LogError(
7147 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7148 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7149 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7150 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7151 }
7152 }
7153 }
7154 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7155 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7156 skip |= LogError(
7157 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7158 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7159 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7160 }
7161 }
7162 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7163 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7164 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7165 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7166 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7167 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7168 }
7169 }
7170 } else if (pInfos[i].ppGeometries) {
7171 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7172 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7173 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7174 skip |= LogError(
7175 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7176 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7177 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7178 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7179 }
7180 } else {
7181 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7182 skip |= LogError(
7183 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7184 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7185 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7186 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7187 }
7188 }
7189 }
7190 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7191 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7192 skip |= LogError(
7193 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7194 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7195 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7196 }
7197 }
7198 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7199 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7200 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7201 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7202 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7203 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7204 }
7205 }
7206 }
7207 }
7208 }
7209 return skip;
7210}
7211
7212bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7213 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7214 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7215 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7216 bool skip = false;
7217 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7218 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007219 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007220 if (!ray_tracing_acceleration_structure_features ||
7221 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7222 skip |=
7223 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7224 "vkBuildAccelerationStructuresKHR: The "
7225 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7226 }
7227 for (uint32_t i = 0; i < infoCount; ++i) {
7228 for (uint32_t j = 0; j < infoCount; ++j) {
7229 if (i == j) continue;
7230 bool found = false;
7231 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7232 skip |= LogError(
7233 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7234 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
7235 "not be "
7236 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7237 i, j);
7238 found = true;
7239 }
7240 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7241 skip |= LogError(
7242 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7243 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
7244 "not be "
7245 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7246 i, j);
7247 found = true;
7248 }
7249 if (found) break;
7250 }
7251 }
7252 return skip;
7253}
7254
7255bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7256 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7257 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7258 bool skip = false;
7259 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7260 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007261 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7262 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007263 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7264 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7265 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7266 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7267 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7268 }
7269 return skip;
7270}
sfricke-samsungecafb192021-01-17 08:21:14 -08007271
7272bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7273 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7274 const VkAllocationCallbacks *pAllocator,
7275 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7276 bool skip = false;
7277 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7278 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7279 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7280 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7281 }
7282 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007283}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007284
7285bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7286 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7287 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7288 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7289 bool skip = false;
7290 const auto *vertex_input_dynamic_state_features =
7291 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7292 const auto *vertex_attribute_divisor_features =
7293 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7294
7295 // VUID-vkCmdSetVertexInputEXT-None-04790
7296 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7297 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7298 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7299 }
7300
7301 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7302 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7303 skip |=
7304 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7305 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7306 }
7307
7308 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7309 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7310 skip |= LogError(
7311 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7312 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7313 }
7314
7315 // VUID-vkCmdSetVertexInputEXT-binding-04793
7316 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7317 bool binding_found = false;
7318 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7319 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7320 binding_found = true;
7321 break;
7322 }
7323 }
7324 if (!binding_found) {
7325 skip |=
7326 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7327 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
7328 }
7329 }
7330
7331 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7332 if (vertexBindingDescriptionCount > 1) {
7333 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7334 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7335 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7336 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7337 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
7338 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
7339 }
7340 }
7341 }
7342 }
7343
7344 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7345 if (vertexAttributeDescriptionCount > 1) {
7346 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7347 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7348 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7349 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7350 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
7351 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
7352 }
7353 }
7354 }
7355 }
7356
7357 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7358 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7359 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
7360 skip |= LogError(
7361 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7362 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
7363 }
7364
7365 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7366 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
7367 skip |= LogError(
7368 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7369 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
7370 binding);
7371 }
7372
7373 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7374 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7375 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7376 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7377 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7378 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7379 binding);
7380 }
7381
7382 if (pVertexBindingDescriptions[binding].divisor > 1) {
7383 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7384 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7385 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7386 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7387 "vertexAttributeInstanceRateDivisor is not enabled",
7388 binding);
7389 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007390 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007391 if (pVertexBindingDescriptions[binding].divisor >
7392 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7393 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007394 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007395 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7396 binding);
7397 }
7398
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007399 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007400 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7401 skip |=
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007402 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007403 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7404 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7405 binding);
7406 }
7407 }
7408 }
7409 }
7410
7411 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007412 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007413 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7414 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007415 device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007416 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7417 attribute);
7418 }
7419
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007420 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007421 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7422 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007423 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007424 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7425 attribute);
7426 }
7427
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007428 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007429 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7430 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007431 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007432 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7433 attribute);
7434 }
7435
7436 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7437 VkFormatProperties properties;
7438 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7439 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7440 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7441 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7442 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7443 attribute);
7444 }
7445 }
7446
7447 return skip;
7448}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007449
7450bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7451 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7452 const void *pValues) const {
7453 bool skip = false;
7454 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7455 // Check that offset + size don't exceed the max.
7456 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7457 if (offset >= max_push_constants_size) {
7458 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7459 "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset,
7460 max_push_constants_size);
7461 }
7462 if (size > max_push_constants_size - offset) {
7463 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
7464 "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.",
7465 offset, size, max_push_constants_size);
7466 }
7467
7468 // size needs to be non-zero and a multiple of 4.
7469 if (size & 0x3) {
7470 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.",
7471 size);
7472 }
7473
7474 // offset needs to be a multiple of 4.
7475 if ((offset & 0x3) != 0) {
7476 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007477 "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007478 }
7479 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007480}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007481
7482bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7483 uint32_t srcCacheCount,
7484 const VkPipelineCache *pSrcCaches) const {
7485 bool skip = false;
7486 if (pSrcCaches) {
7487 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7488 if (pSrcCaches[index0] == dstCache) {
7489 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7490 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7491 report_data->FormatHandle(dstCache).c_str());
7492 break;
7493 }
7494 }
7495 }
7496 return skip;
7497}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007498
7499bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
7500 VkImageLayout imageLayout, const VkClearColorValue *pColor,
7501 uint32_t rangeCount,
7502 const VkImageSubresourceRange *pRanges) const {
7503 bool skip = false;
7504 if (!pColor) {
7505 skip |=
7506 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
7507 }
7508 return skip;
7509}
7510
7511bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
7512 const VkRenderPassBeginInfo *const rp_begin) const {
7513 bool skip = false;
7514 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
7515 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
7516 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02007517 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007518 func_name, rp_begin->clearValueCount);
7519 }
7520 return skip;
7521}
7522
7523bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7524 VkSubpassContents) const {
7525 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
7526 return skip;
7527}
7528
7529bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
7530 const VkRenderPassBeginInfo *pRenderPassBegin,
7531 const VkSubpassBeginInfo *) const {
7532 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
7533 return skip;
7534}
7535
7536bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7537 const VkSubpassBeginInfo *) const {
7538 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
7539 return skip;
7540}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02007541
7542bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
7543 uint32_t firstDiscardRectangle,
7544 uint32_t discardRectangleCount,
7545 const VkRect2D *pDiscardRectangles) const {
7546 bool skip = false;
7547
7548 if (pDiscardRectangles) {
7549 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
7550 const int64_t x_sum =
7551 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
7552 if (x_sum > std::numeric_limits<int32_t>::max()) {
7553 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
7554 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7555 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7556 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
7557 }
7558
7559 const int64_t y_sum =
7560 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
7561 if (y_sum > std::numeric_limits<int32_t>::max()) {
7562 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
7563 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7564 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7565 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
7566 }
7567 }
7568 }
7569
7570 return skip;
7571}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02007572
7573bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
7574 uint32_t queryCount, size_t dataSize, void *pData,
7575 VkDeviceSize stride, VkQueryResultFlags flags) const {
7576 bool skip = false;
7577
7578 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
7579 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
7580 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
7581 }
7582
7583 return skip;
7584}
ziga-lunargcf340c42021-08-19 00:13:38 +02007585
7586bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
7587 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
7588 bool skip = false;
7589
7590 if ((pConditionalRenderingBegin->offset & 3) != 0) {
7591 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
7592 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
7593 ") is not a multiple of 4.",
7594 pConditionalRenderingBegin->offset);
7595 }
7596
7597 return skip;
7598}