blob: f4380c2d0231650eebddc8d8baef3906c1e8bd1e [file] [log] [blame]
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070028static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060029
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070036read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); }
37write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); }
38
Jeremy Gebbencbf22862021-03-03 12:01:22 -070039static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070040static ReadWriteLock secondary_cb_map_mutex;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -070041static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); }
42static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070044bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050045 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060046 bool skip = false;
47
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070048 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060049
50 if (result == VK_STRING_ERROR_NONE) {
51 return skip;
52 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070053 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070054 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060055 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070056 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
57 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060058 }
59 return skip;
60}
61
Jeff Bolz46c0ea02019-10-09 13:06:29 -050062bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060063 bool skip = false;
64 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
65 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080066 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
67 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070068 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
69 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
70 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060071 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070072 skip |= LogWarning(instance, kVUIDUndefined,
73 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
74 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
75 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060076 }
77 }
78 return skip;
79}
80
Jeff Bolz46c0ea02019-10-09 13:06:29 -050081bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060082 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060083 // Create and use a local instance extension object, as an actual instance has not been created yet
84 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
85 InstanceExtensions local_instance_extensions;
86 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
87
John Zulauf620755c2018-04-16 11:00:43 -060088 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060089 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
90 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060091 }
92
93 return skip;
94}
95
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060096bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -070097 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060098 // Struct is legal IF it's supported
99 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
100 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
101 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
102 if (enum_iter != dev_exts_enumerated->second.cend()) {
103 return true;
104 }
105 }
106 return false;
107}
108
Tony-LunarG866843d2020-05-13 11:22:42 -0600109bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
110 const VkValidationFeaturesEXT *validation_features) const {
111 bool skip = false;
112 bool debug_printf = false;
113 bool gpu_assisted = false;
114 bool reserve_slot = false;
115 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
116 switch (validation_features->pEnabledValidationFeatures[i]) {
117 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
118 gpu_assisted = true;
119 break;
120
121 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
122 debug_printf = true;
123 break;
124
125 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
126 reserve_slot = true;
127 break;
128
129 default:
130 break;
131 }
132 }
133 if (reserve_slot && !gpu_assisted) {
134 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
135 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
136 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
137 }
138 if (gpu_assisted && debug_printf) {
139 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
140 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
141 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
142 }
143
144 return skip;
145}
146
John Zulauf620755c2018-04-16 11:00:43 -0600147template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700148ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
149 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600150 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700151 ExtEnabled state =
152 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600153 return state;
154}
155
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700156bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500157 const VkAllocationCallbacks *pAllocator,
158 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 bool skip = false;
160 // Note: From the spec--
161 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
162 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
163 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700164 ? pCreateInfo->pApplicationInfo->apiVersion
165 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700166 skip |= validate_api_version(local_api_version, api_version);
167 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700168 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600169 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
170
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700171 return skip;
172}
173
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700174void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700175 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
176 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700177 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
178 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700179 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700180 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700181}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600182
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700183void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
184 // Assume phys_devices is valid
185 assert(phys_devices);
186 for (int i = 0; i < count; ++i) {
187 const auto &phys_device = phys_devices[i];
188 if (0 == physical_device_properties_map.count(phys_device)) {
189 auto phys_dev_props = new VkPhysicalDeviceProperties;
190 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
191 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600192
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700193 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
194 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700195 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700196 std::vector<VkExtensionProperties> ext_props{};
197 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
198 ext_props.resize(ext_count);
199 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
200 for (uint32_t j = 0; j < ext_count; j++) {
201 dev_exts_enumerated.insert(ext_props[j].extensionName);
202 }
203 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600204 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700205 }
206}
207
208void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
209 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
210 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
211 return;
212 }
213
214 if (pPhysicalDeviceCount && pPhysicalDevices) {
215 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
216 }
217}
218
219void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
220 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
221 VkResult result) {
222 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
223 return;
224 }
225
226 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
227 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
228 const auto &group = pPhysicalDeviceGroupProperties[i];
229 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
230 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600231 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700232}
233
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600234void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
235 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
236 delete (it->second);
237 it = physical_device_properties_map.erase(it);
238 }
239};
240
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700241void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700242 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700243 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700244 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700245 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
246 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700247
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248 // Parmeter validation also uses extension data
249 stateless_validation->device_extensions = this->device_extensions;
250
251 VkPhysicalDeviceProperties device_properties = {};
252 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600253 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700254 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
255
sfricke-samsung45996a42021-09-16 13:45:27 -0700256 if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700257 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700258 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
259 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600260 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700261 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
262 }
263
sfricke-samsung45996a42021-09-16 13:45:27 -0700264 if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700265 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700266 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
267 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600268 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700269 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
270 }
271
sfricke-samsung45996a42021-09-16 13:45:27 -0700272 if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) {
Jason Macnak5c954952019-07-09 15:46:12 -0700273 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700274 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
275 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700276 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500277 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
278 }
279
sfricke-samsung45996a42021-09-16 13:45:27 -0700280 if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500281 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700282 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
283 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500284 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
285 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700286 }
287
sfricke-samsung45996a42021-09-16 13:45:27 -0700288 if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) {
sourav parmarcd5fb182020-07-17 12:58:44 -0700289 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700290 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
291 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700292 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
293 phys_dev_ext_props.acc_structure_props = acc_structure_props;
294 }
295
sfricke-samsung45996a42021-09-16 13:45:27 -0700296 if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) {
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700297 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700298 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
299 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700300 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
301 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
302 }
303
sfricke-samsung45996a42021-09-16 13:45:27 -0700304 if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) {
Piers Daniellcb6d8032021-04-19 18:51:26 -0600305 // Get the needed vertex attribute divisor limits
306 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
307 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
308 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
309 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
310 }
311
sfricke-samsung45996a42021-09-16 13:45:27 -0700312 if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) {
ziga-lunarga283d022021-08-04 18:35:23 +0200313 // Get the needed vertex attribute divisor limits
314 auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>();
315 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props);
316 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
317 phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props;
318 }
319
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800320 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
321
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700322 // Save app-enabled features in this device's validation object
323 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700324 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200325 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
326 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
327 if (features2) {
328 tmp_features2_state.features = features2->features;
329 } else if (pCreateInfo->pEnabledFeatures) {
330 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700331 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200332 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700333 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200334 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700335 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200336 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700337}
338
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700339bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500340 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600341 bool skip = false;
342
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200343 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
344 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
345 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600346 }
347
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700348 // If this device supports VK_KHR_portability_subset, it must be enabled
349 const std::string portability_extension_name("VK_KHR_portability_subset");
350 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
351 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
352 bool portability_requested = false;
353
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200354 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
355 skip |=
356 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
357 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
358 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
359 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700360 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
361 portability_requested = true;
362 }
363 }
364
365 if (portability_supported && !portability_requested) {
366 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
367 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
368 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600369 }
370
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200371 {
Mike Schuchardt7cc57842021-09-15 10:49:59 -0700372 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME));
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700373 bool negative_viewport =
374 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200375 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700376 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
377 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
378 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200379 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600380 }
381
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600382 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200383 bool khr_bda =
384 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
385 bool ext_bda =
386 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600387 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700388 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
389 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
390 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600391 }
392 }
393
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600394 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
395 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700396 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600397 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800398 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700399 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800400 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700401 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600402 }
403 }
404
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700405 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500406 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700407 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500408 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
409 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
410 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
411 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700412 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700413 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
414 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
415 skip |= LogError(
416 device,
417 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
418 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
419 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700420 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700421 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -0700422 if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) {
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600423 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
424 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
425 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600426 }
427
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700428 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700429 if (vulkan_11_features) {
430 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
431 while (current) {
432 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
433 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
434 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
435 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
436 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
437 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700438 skip |= LogError(
439 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700440 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
441 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
442 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
443 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
444 break;
445 }
446 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
447 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800448
449 // Check features are enabled if matching extension is passed in as well
450 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
451 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
452 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
453 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
454 skip |= LogError(
455 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
456 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
457 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
458 }
459 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700460 }
461
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700462 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700463 if (vulkan_12_features) {
464 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
465 while (current) {
466 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
467 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
469 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
470 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
471 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
472 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
473 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
474 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
475 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
476 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
477 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
478 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700479 skip |= LogError(
480 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700481 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
482 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
483 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
484 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
485 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
486 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
487 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
488 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
489 break;
490 }
491 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
492 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700493 // Check features are enabled if matching extension is passed in as well
494 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
495 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
496 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
497 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
498 skip |= LogError(
499 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
500 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
501 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
502 }
503 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
504 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
505 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
506 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
507 "is not VK_TRUE.",
508 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
509 }
510 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
511 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
512 skip |= LogError(
513 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
514 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
515 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
516 }
517 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
518 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
519 skip |= LogError(
520 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
521 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
522 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
523 }
524 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
525 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
526 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
527 skip |=
528 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
529 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
530 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
531 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
532 }
533 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200534 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
535 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
536 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
537 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
538 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
539 }
540 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700541 }
542
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600543 // Validate pCreateInfo->pQueueCreateInfos
544 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600545
546 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700547 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
548 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700550 skip |=
551 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
552 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
553 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
554 "index value.",
555 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600556 }
557
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700558 if (queue_create_info.pQueuePriorities != nullptr) {
559 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
560 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600561 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700562 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
563 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
564 "] (=%f) is not between 0 and 1 (inclusive).",
565 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600566 }
567 }
568 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700569
570 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700571 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700572 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700573 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700574 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700575 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700576 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700577 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700578 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700579 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700580 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
581 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
582 "protectedMemory feature being set as well.");
583 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600584 }
585 }
586
sfricke-samsung30a57412020-05-15 21:14:54 -0700587 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700588 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700589 VkBool32 variable_pointers = VK_FALSE;
590 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700591 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700592 variable_pointers = vulkan_11_features->variablePointers;
593 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700594 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700595 variable_pointers = variable_pointers_features->variablePointers;
596 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700597 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700598 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700599 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
600 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
601 }
602
sfricke-samsungfd76c342020-05-29 23:13:43 -0700603 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700604 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700605 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700606 VkBool32 multiview_geometry_shader = VK_FALSE;
607 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700608 if (vulkan_11_features) {
609 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700610 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
611 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700612 } else if (multiview_features) {
613 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700614 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
615 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700616 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700617 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700618 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
619 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
620 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700621 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700622 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
623 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
624 }
625
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 return skip;
627}
628
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500629bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700630 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700631 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
632 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
633 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600634 }
635
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700636 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600637}
638
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700639bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500640 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100641 bool skip = false;
642
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600643 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |=
645 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600646
647 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
648 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
649 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
650 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700651 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
652 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
653 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600654 }
655
656 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
657 // queueFamilyIndexCount uint32_t values
658 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700659 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
660 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
661 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
662 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600663 }
664 }
665
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700666 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
667 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
668 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
669 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
670 }
671
672 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
673 skip |=
674 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
675 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
676 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
677 }
678
679 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
680 skip |=
681 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
682 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
683 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
684 }
685
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600686 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
687 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
688 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
689 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700690 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
691 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
692 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600693 }
694 }
695
696 return skip;
697}
698
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700699bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500700 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600701 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600702
703 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800704 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700705 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600706 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
707 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
708 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
709 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
711 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
712 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600713 }
714
715 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
716 // queueFamilyIndexCount uint32_t values
717 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
719 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
720 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
721 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600722 }
723 }
724
Dave Houlton413a6782018-05-22 13:01:54 -0600725 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600727 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600729 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700730 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600731
Dave Houlton413a6782018-05-22 13:01:54 -0600732 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700733 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600734 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700735 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600736
Dave Houlton130c0212018-01-29 13:39:56 -0700737 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700738 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
739 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 skip |= LogError(
741 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600742 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
743 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700744 }
745
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600746 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100747 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
748 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700749 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
750 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
751 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600752 }
753
754 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700755 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100756 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700757 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
758 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
759 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
760 ") are not equal.",
761 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100762 }
763
764 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700765 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
766 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
767 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
768 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100769 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600770 }
771
772 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(
774 device, "VUID-VkImageCreateInfo-imageType-00957",
775 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600776 }
777 }
778
Dave Houlton130c0212018-01-29 13:39:56 -0700779 // 3D image may have only 1 layer
780 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
782 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700783 }
784
Dave Houlton130c0212018-01-29 13:39:56 -0700785 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
786 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
787 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
788 // At least one of the legal attachment bits must be set
789 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700790 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
791 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700792 }
793 // No flags other than the legal attachment bits may be set
794 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
795 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700796 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
797 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700798 }
799 }
800
Jeff Bolzef40fec2018-09-01 22:04:34 -0500801 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700802 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500803 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700804 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700805 ? static_cast<uint32_t>(ceil(log2(max_dim)))
806 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
807 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600808 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700809 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
810 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
811 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600812 }
813
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700814 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700815 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
816 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
817 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600818 }
819
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700820 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
822 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
823 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100824 }
825
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700826 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700827 skip |= LogError(
828 device, "VUID-VkImageCreateInfo-flags-01924",
829 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
830 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
831 }
832
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600833 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
834 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700835 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
836 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700837 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
838 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
839 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600840 }
841
842 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700843 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600844 // Linear tiling is unsupported
845 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700846 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700847 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
848 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600849 }
850
851 // Sparse 1D image isn't valid
852 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700853 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
854 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600855 }
856
857 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700858 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
860 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
861 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600862 }
863
864 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700865 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700866 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
867 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
868 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600869 }
870
871 // Multi-sample 2D image when device doesn't support it
872 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700873 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600874 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700875 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
876 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
877 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700878 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600879 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700880 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
881 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
882 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700883 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600884 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700885 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
886 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
887 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700888 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600889 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700890 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
891 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
892 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600893 }
894 }
895 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500896
Jeff Bolz9af91c52018-09-01 21:53:57 -0500897 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
898 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700899 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
900 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
901 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500902 }
903 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700904 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
905 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
906 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500907 }
908 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700909 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
910 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
911 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500912 }
913 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500914
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700915 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600916 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700917 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
918 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
919 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500920 }
921
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700922 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700923 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
924 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800925 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
926 "depth/stencil format.",
927 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500928 }
929
Dave Houlton142c4cb2018-10-17 15:04:41 -0600930 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700931 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
932 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
933 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
934 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500935 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600936 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700937 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
938 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
939 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
940 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500941 }
942 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500943
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700944 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800945 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700946 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
947 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800948 "format (%s) must be a depth or depth/stencil format.",
949 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700950 }
951
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700952 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500953 if (image_stencil_struct != nullptr) {
954 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
955 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
956 // No flags other than the legal attachment bits may be set
957 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
958 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700959 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
960 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
961 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
962 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500963 }
964 }
965
sfricke-samsung61a57c02021-01-10 21:35:12 -0800966 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500967 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
968 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800969 skip |= LogError(
970 device, "VUID-VkImageCreateInfo-Format-02536",
971 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
972 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
973 "maxFramebufferWidth (%u)",
974 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500975 }
976
977 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800978 skip |= LogError(
979 device, "VUID-VkImageCreateInfo-format-02537",
980 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
981 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
982 "maxFramebufferHeight (%u)",
983 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500984 }
985 }
986
987 if (!physical_device_features.shaderStorageImageMultisample &&
988 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
989 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
990 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700991 LogError(device, "VUID-VkImageCreateInfo-format-02538",
992 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
993 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
994 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500995 }
996
997 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
998 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700999 skip |= LogError(
1000 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001001 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1002 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1003 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1004 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1005 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001006 skip |= LogError(
1007 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001008 "vkCreateImage(): Depth-stencil image in which usage does not include "
1009 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1010 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1011 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1012 }
1013
1014 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1015 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001016 skip |= LogError(
1017 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001018 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1019 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1020 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1021 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1022 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001023 skip |= LogError(
1024 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001025 "vkCreateImage(): Depth-stencil image in which usage does not include "
1026 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1027 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1028 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1029 }
1030 }
1031 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001032
1033 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1034 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1035 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1036 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1037 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1038 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001039
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001040 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001041 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001042 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1043 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001044 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1045 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1046 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1047 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1048 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1049 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1050 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001051 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001052 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1053 } else if (drm_format_mod_list != nullptr) {
1054 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1055 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1056 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001057 }
1058 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1059 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1060 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1061 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1062 "in the pNext chain");
1063 }
1064 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001065
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001066 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001067 bool image_create_maybe_linear = false;
1068 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1069 image_create_maybe_linear = true;
1070 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1071 image_create_maybe_linear = false;
1072 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1073 image_create_maybe_linear =
1074 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001075 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001076 }
1077
1078 // If multi-sample, validate type, usage, tiling and mip levels.
1079 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001080 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001081 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1082 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1083 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1084 }
1085
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001086 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001087 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1088 image_create_maybe_linear)) {
1089 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1090 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1091 }
1092
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001093 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1094 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1095 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1096 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1097 "imageType must be VK_IMAGE_TYPE_2D.");
1098 }
1099 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1100 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1101 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1102 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1103 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001104 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001105 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001106 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1107 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1108 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1109 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1110 }
1111 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1112 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1113 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1114 "imageType must be VK_IMAGE_TYPE_2D.");
1115 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001116 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001117 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1118 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1119 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1120 }
1121 if (pCreateInfo->mipLevels != 1) {
1122 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1123 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1124 pCreateInfo->mipLevels);
1125 }
1126 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001127
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001128 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001129 if (swapchain_create_info != nullptr) {
1130 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1131 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1132 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1133 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1134 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1135 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1136
1137 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1138 // also implicitly forces the check above that extent.depth is 1
1139 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1140 string_VkImageType(pCreateInfo->imageType));
1141 }
1142 if (pCreateInfo->mipLevels != 1) {
1143 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1144 pCreateInfo->mipLevels);
1145 }
1146 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1147 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1148 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1149 }
1150 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1151 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1152 base_message, string_VkImageTiling(pCreateInfo->tiling));
1153 }
1154 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1155 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1156 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1157 }
1158 const VkImageCreateFlags valid_flags =
1159 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001160 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001161 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001162 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001163 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001164 }
1165 }
1166 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001167
1168 // If Chroma subsampled format ( _420_ or _422_ )
1169 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1170 skip |=
1171 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1172 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1173 ") must be a multiple of 2.",
1174 string_VkFormat(image_format), pCreateInfo->extent.width);
1175 }
1176 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1177 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1178 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1179 ") must be a multiple of 2.",
1180 string_VkFormat(image_format), pCreateInfo->extent.height);
1181 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001182
1183 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1184 if (format_list_info) {
1185 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1186 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1187 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1188 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1189 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1190 viewFormatCount);
1191 }
1192 // Check if viewFormatCount is not zero that it is all compatible
1193 for (uint32_t i = 0; i < viewFormatCount; i++) {
1194 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1195 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1196 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1197 "VkImageCreateInfo::format (%s) are not compatible.",
1198 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1199 }
1200 }
1201 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001202 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001203
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001204 return skip;
1205}
1206
Jeff Bolz99e3f632020-03-24 22:59:22 -05001207bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1208 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1209 bool skip = false;
1210
1211 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001212 // Validate feature set if using CUBE_ARRAY
1213 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1214 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1215 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1216 "enabling the imageCubeArray feature.");
1217 }
1218
Jeff Bolz99e3f632020-03-24 22:59:22 -05001219 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1220 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1221 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001222 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001223 pCreateInfo->subresourceRange.layerCount);
1224 }
1225 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001226 skip |= LogError(
1227 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1228 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1229 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001230 }
1231 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001232
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001233 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001234 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001235 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1236 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1237 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1238 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1239 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1240 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1241 }
1242 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1243 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1244 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1245 "not an ASTC format.",
1246 string_VkFormat(pCreateInfo->format));
1247 }
1248 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001249
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001250 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001251 if (ycbcr_conversion != nullptr) {
1252 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1253 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1254 skip |= LogError(
1255 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1256 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1257 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1258 "r swizzle = %s\n"
1259 "g swizzle = %s\n"
1260 "b swizzle = %s\n"
1261 "a swizzle = %s\n",
1262 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1263 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1264 }
1265 }
1266 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001267 }
1268 return skip;
1269}
1270
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001271bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001272 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001273 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001274
1275 // Note: for numerical correctness
1276 // - float comparisons should expect NaN (comparison always false).
1277 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1278
1279 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001280 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001281 if (v1_f <= 0.0f) return true;
1282
1283 float intpart;
1284 const float fract = modff(v1_f, &intpart);
1285
1286 assert(std::numeric_limits<float>::radix == 2);
1287 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1288 if (intpart >= u32_max_plus1) return false;
1289
1290 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001291 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001292 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001293 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001294 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001295 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001296 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001297 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001298 };
1299
1300 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1301 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1302 return (v1_f <= v2_f);
1303 };
1304
1305 // width
1306 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001307 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001308
1309 if (!(viewport.width > 0.0f)) {
1310 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001311 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1312 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001313 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1314 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001315 skip |= LogError(object, "VUID-VkViewport-width-01771",
1316 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1317 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001318 }
1319
1320 // height
1321 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001322 const bool negative_height_enabled =
1323 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001324 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001325
1326 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1327 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001328 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1329 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001330 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1331 height_healthy = false;
1332
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001333 skip |= LogError(object, "VUID-VkViewport-height-01773",
1334 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1335 ").",
1336 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001337 }
1338
1339 // x
1340 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001341 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001342 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001343 skip |= LogError(object, "VUID-VkViewport-x-01774",
1344 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1345 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001346 }
1347
1348 // x + width
1349 if (x_healthy && width_healthy) {
1350 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001351 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001352 skip |= LogError(
1353 object, "VUID-VkViewport-x-01232",
1354 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1355 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1356 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001357 }
1358 }
1359
1360 // y
1361 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001362 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001363 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001364 skip |= LogError(object, "VUID-VkViewport-y-01775",
1365 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1366 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001367 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001368 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001369 skip |= LogError(object, "VUID-VkViewport-y-01776",
1370 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1371 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001372 }
1373
1374 // y + height
1375 if (y_healthy && height_healthy) {
1376 const float boundary = viewport.y + viewport.height;
1377
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001378 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001379 skip |= LogError(object, "VUID-VkViewport-y-01233",
1380 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1381 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1382 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001383 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001384 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001385 LogError(object, "VUID-VkViewport-y-01777",
1386 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1387 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1388 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001389 }
1390 }
1391
sfricke-samsungfd06d422021-01-22 02:17:21 -08001392 // 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 -07001393 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001394 // minDepth
1395 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001396 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001397 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001398 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1399 "[0.0, 1.0] range.",
1400 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001401 }
1402
1403 // maxDepth
1404 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001405 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001406 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001407 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1408 "[0.0, 1.0] range.",
1409 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001410 }
1411 }
1412
1413 return skip;
1414}
1415
Dave Houlton142c4cb2018-10-17 15:04:41 -06001416struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001417 VkShadingRatePaletteEntryNV shadingRate;
1418 uint32_t width;
1419 uint32_t height;
1420};
1421
1422// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001423static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001424 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1425 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1426 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1427 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1428 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1429 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001430};
1431
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001432bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001433 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001434
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001435 SampleOrderInfo *sample_order_info;
1436 uint32_t info_idx = 0;
1437 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1438 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1439 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001440 break;
1441 }
1442 }
1443
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001444 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001445 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1446 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1447 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001448 return skip;
1449 }
1450
Dave Houlton142c4cb2018-10-17 15:04:41 -06001451 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001452 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001453 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1454 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1455 ") must "
1456 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1457 "is set in framebufferNoAttachmentsSampleCounts.",
1458 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001459 }
1460
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001461 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001462 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1463 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1464 ") must "
1465 "be equal to the product of sampleCount (=%" PRIu32
1466 "), the fragment width for shadingRate "
1467 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001468 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001469 }
1470
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001471 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001472 skip |= LogError(
1473 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001474 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1475 ") must "
1476 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001477 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001478 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001479
1480 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001481 // the first width*height*sampleCount bits to all be set. Note: There is no
1482 // guarantee that 64 bits is enough, but practically it's unlikely for an
1483 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001484 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001485 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001486 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001487 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1488 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001489 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1490 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001491 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001492 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001493 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1494 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001495 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001496 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001497 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1498 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001499 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001500 uint32_t idx =
1501 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1502 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001503 }
1504
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001505 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1506 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001507 skip |= LogError(
1508 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001509 "The array pSampleLocations must contain exactly one entry for "
1510 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001511 }
1512
1513 return skip;
1514}
1515
sfricke-samsung51303fb2021-05-09 19:09:13 -07001516bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1517 const VkAllocationCallbacks *pAllocator,
1518 VkPipelineLayout *pPipelineLayout) const {
1519 bool skip = false;
1520 // Validate layout count against device physical limit
1521 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1522 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
1523 "vkCreatePipelineLayout(): setLayoutCount (%d) exceeds physical device maxBoundDescriptorSets limit (%d).",
1524 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1525 }
1526
1527 // Validate Push Constant ranges
1528 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1529 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1530 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1531 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1532 // Check that offset + size don't exceed the max.
1533 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1534 if (offset >= max_push_constants_size) {
1535 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
1536 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) that exceeds this "
1537 "device's maxPushConstantSize of %u.",
1538 i, offset, max_push_constants_size);
1539 }
1540 if (size > max_push_constants_size - offset) {
1541 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
1542 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u] offset (%u) and size (%u) "
1543 "together exceeds this device's maxPushConstantSize of %u.",
1544 i, offset, size, max_push_constants_size);
1545 }
1546
1547 // size needs to be non-zero and a multiple of 4.
1548 if (size == 0) {
1549 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
1550 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not greater than zero.",
1551 i, size);
1552 }
1553 if (size & 0x3) {
1554 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
1555 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not a multiple of 4.", i,
1556 size);
1557 }
1558
1559 // offset needs to be a multiple of 4.
1560 if ((offset & 0x3) != 0) {
1561 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
1562 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) is not a multiple of 4.",
1563 i, offset);
1564 }
1565 }
1566
1567 // 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.
1568 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1569 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1570 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
1571 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1572 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %d and %d.", i, j);
1573 }
1574 }
1575 }
1576 return skip;
1577}
1578
ziga-lunargc6341372021-07-28 12:57:42 +02001579bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1580 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1581 bool skip = false;
1582
1583 const auto *required_subgroup_size_features =
1584 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1585
1586 if (required_subgroup_size_features) {
1587 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1588 skip |= LogError(
1589 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1590 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1591 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1592 func_name, msg, pCreateInfo->flags);
1593 }
1594 }
1595
1596 return skip;
1597}
1598
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001599bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1600 uint32_t createInfoCount,
1601 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1602 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001603 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001604 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001605
1606 if (pCreateInfos != nullptr) {
1607 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001608 bool has_dynamic_viewport = false;
1609 bool has_dynamic_scissor = false;
1610 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001611 bool has_dynamic_depth_bias = false;
1612 bool has_dynamic_blend_constant = false;
1613 bool has_dynamic_depth_bounds = false;
1614 bool has_dynamic_stencil_compare = false;
1615 bool has_dynamic_stencil_write = false;
1616 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001617 bool has_dynamic_viewport_w_scaling_nv = false;
1618 bool has_dynamic_discard_rectangle_ext = false;
1619 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001620 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001621 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001622 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001623 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001624 bool has_dynamic_cull_mode = false;
1625 bool has_dynamic_front_face = false;
1626 bool has_dynamic_primitive_topology = false;
1627 bool has_dynamic_viewport_with_count = false;
1628 bool has_dynamic_scissor_with_count = false;
1629 bool has_dynamic_vertex_input_binding_stride = false;
1630 bool has_dynamic_depth_test_enable = false;
1631 bool has_dynamic_depth_write_enable = false;
1632 bool has_dynamic_depth_compare_op = false;
1633 bool has_dynamic_depth_bounds_test_enable = false;
1634 bool has_dynamic_stencil_test_enable = false;
1635 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001636 bool has_patch_control_points = false;
1637 bool has_rasterizer_discard_enable = false;
1638 bool has_depth_bias_enable = false;
1639 bool has_logic_op = false;
1640 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001641 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001642 if (pCreateInfos[i].pDynamicState != nullptr) {
1643 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1644 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1645 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001646 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1647 if (has_dynamic_viewport == true) {
1648 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1649 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1650 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1651 i);
1652 }
1653 has_dynamic_viewport = true;
1654 }
1655 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1656 if (has_dynamic_scissor == true) {
1657 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1658 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1659 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1660 i);
1661 }
1662 has_dynamic_scissor = true;
1663 }
1664 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1665 if (has_dynamic_line_width == true) {
1666 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1667 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1668 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1669 i);
1670 }
1671 has_dynamic_line_width = true;
1672 }
1673 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1674 if (has_dynamic_depth_bias == true) {
1675 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1676 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1677 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1678 i);
1679 }
1680 has_dynamic_depth_bias = true;
1681 }
1682 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1683 if (has_dynamic_blend_constant == true) {
1684 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1685 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1686 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1687 i);
1688 }
1689 has_dynamic_blend_constant = true;
1690 }
1691 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1692 if (has_dynamic_depth_bounds == true) {
1693 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1694 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1695 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1696 i);
1697 }
1698 has_dynamic_depth_bounds = true;
1699 }
1700 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1701 if (has_dynamic_stencil_compare == true) {
1702 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1703 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1704 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1705 i);
1706 }
1707 has_dynamic_stencil_compare = true;
1708 }
1709 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1710 if (has_dynamic_stencil_write == true) {
1711 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1712 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1713 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1714 i);
1715 }
1716 has_dynamic_stencil_write = true;
1717 }
1718 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1719 if (has_dynamic_stencil_reference == true) {
1720 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1721 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1722 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1723 i);
1724 }
1725 has_dynamic_stencil_reference = true;
1726 }
1727 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1728 if (has_dynamic_viewport_w_scaling_nv == true) {
1729 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1730 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1731 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1732 i);
1733 }
1734 has_dynamic_viewport_w_scaling_nv = true;
1735 }
1736 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1737 if (has_dynamic_discard_rectangle_ext == true) {
1738 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1739 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1740 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1741 i);
1742 }
1743 has_dynamic_discard_rectangle_ext = true;
1744 }
1745 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1746 if (has_dynamic_sample_locations_ext == true) {
1747 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1748 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1749 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1750 i);
1751 }
1752 has_dynamic_sample_locations_ext = true;
1753 }
1754 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1755 if (has_dynamic_exclusive_scissor_nv == true) {
1756 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1757 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1758 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1759 i);
1760 }
1761 has_dynamic_exclusive_scissor_nv = true;
1762 }
1763 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1764 if (has_dynamic_shading_rate_palette_nv == true) {
1765 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1766 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1767 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1768 i);
1769 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001770 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001771 }
1772 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1773 if (has_dynamic_viewport_course_sample_order_nv == true) {
1774 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1775 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1776 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1777 i);
1778 }
1779 has_dynamic_viewport_course_sample_order_nv = true;
1780 }
1781 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1782 if (has_dynamic_line_stipple == true) {
1783 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1784 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1785 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1786 i);
1787 }
1788 has_dynamic_line_stipple = true;
1789 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001790 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1791 if (has_dynamic_cull_mode) {
1792 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1793 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1794 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1795 i);
1796 }
1797 has_dynamic_cull_mode = true;
1798 }
1799 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1800 if (has_dynamic_front_face) {
1801 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1802 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1803 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1804 i);
1805 }
1806 has_dynamic_front_face = true;
1807 }
1808 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1809 if (has_dynamic_primitive_topology) {
1810 skip |= LogError(
1811 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1812 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1813 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1814 i);
1815 }
1816 has_dynamic_primitive_topology = true;
1817 }
1818 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1819 if (has_dynamic_viewport_with_count) {
1820 skip |= LogError(
1821 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1822 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1823 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1824 i);
1825 }
1826 has_dynamic_viewport_with_count = true;
1827 }
1828 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1829 if (has_dynamic_scissor_with_count) {
1830 skip |= LogError(
1831 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1832 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1833 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1834 i);
1835 }
1836 has_dynamic_scissor_with_count = true;
1837 }
1838 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1839 if (has_dynamic_vertex_input_binding_stride) {
1840 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1841 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1842 "listed twice in the "
1843 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1844 i);
1845 }
1846 has_dynamic_vertex_input_binding_stride = true;
1847 }
1848 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1849 if (has_dynamic_depth_test_enable) {
1850 skip |= LogError(
1851 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1852 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1853 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1854 i);
1855 }
1856 has_dynamic_depth_test_enable = true;
1857 }
1858 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1859 if (has_dynamic_depth_write_enable) {
1860 skip |= LogError(
1861 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1862 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1863 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1864 i);
1865 }
1866 has_dynamic_depth_write_enable = true;
1867 }
1868 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1869 if (has_dynamic_depth_compare_op) {
1870 skip |=
1871 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1872 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1873 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1874 i);
1875 }
1876 has_dynamic_depth_compare_op = true;
1877 }
1878 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1879 if (has_dynamic_depth_bounds_test_enable) {
1880 skip |= LogError(
1881 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1882 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1883 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1884 i);
1885 }
1886 has_dynamic_depth_bounds_test_enable = true;
1887 }
1888 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1889 if (has_dynamic_stencil_test_enable) {
1890 skip |= LogError(
1891 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1892 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1893 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1894 i);
1895 }
1896 has_dynamic_stencil_test_enable = true;
1897 }
1898 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1899 if (has_dynamic_stencil_op) {
1900 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1901 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1902 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1903 i);
1904 }
1905 has_dynamic_stencil_op = true;
1906 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001907 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1908 // Not allowed for graphics pipelines
1909 skip |= LogError(
1910 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1911 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1912 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1913 i, state_index);
1914 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001915 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1916 if (has_patch_control_points) {
1917 skip |= LogError(
1918 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1919 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1920 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1921 i);
1922 }
1923 has_patch_control_points = true;
1924 }
1925 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1926 if (has_rasterizer_discard_enable) {
1927 skip |= LogError(
1928 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1929 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1930 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1931 i);
1932 }
1933 has_rasterizer_discard_enable = true;
1934 }
1935 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1936 if (has_depth_bias_enable) {
1937 skip |= LogError(
1938 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1939 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1940 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1941 i);
1942 }
1943 has_depth_bias_enable = true;
1944 }
1945 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1946 if (has_logic_op) {
1947 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1948 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1949 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1950 i);
1951 }
1952 has_logic_op = true;
1953 }
1954 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1955 if (has_primitive_restart_enable) {
1956 skip |= LogError(
1957 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1958 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1959 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1960 i);
1961 }
1962 has_primitive_restart_enable = true;
1963 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001964 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1965 if (has_dynamic_vertex_input) {
1966 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1967 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1968 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1969 i);
1970 }
1971 has_dynamic_vertex_input = true;
1972 }
Petr Kraus299ba622017-11-24 03:09:03 +01001973 }
1974 }
1975
sfricke-samsung3b944422021-01-23 02:15:19 -08001976 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1977 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1978 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1979 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1980 i);
1981 }
1982
1983 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1984 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1985 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1986 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1987 i);
1988 }
1989
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001990 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001991 if ((feedback_struct != nullptr) &&
1992 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001993 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1994 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1995 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1996 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1997 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001998 }
1999
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002000 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002001
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002002 // Collect active stages and other information
2003 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002004 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002005 bool has_eval = false;
2006 bool has_control = false;
2007 if (pCreateInfos[i].pStages != nullptr) {
2008 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
2009 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
2010
2011 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
2012 has_control = true;
2013 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
2014 has_eval = true;
2015 }
2016
2017 skip |= validate_string(
2018 "vkCreateGraphicsPipelines",
2019 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2020 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002021
2022 std::stringstream msg;
2023 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2024 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2025 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002026 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002027 }
2028
2029 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2030 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2031 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2032 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2033 pCreateInfos[i].pTessellationState,
2034 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2035 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2036
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002037 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002038 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2039
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002040 skip |= validate_struct_pnext(
2041 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2042 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2043 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2044 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2045 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2046 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002047
2048 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2049 pCreateInfos[i].pTessellationState->flags,
2050 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2051 }
2052
2053 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2054 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2055 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2056 pCreateInfos[i].pInputAssemblyState,
2057 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2058 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2059
2060 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2061 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002062 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002063
2064 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2065 pCreateInfos[i].pInputAssemblyState->flags,
2066 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2067
2068 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2069 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2070 pCreateInfos[i].pInputAssemblyState->topology,
2071 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2072
2073 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2074 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2075 }
2076
2077 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002078 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002079
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002080 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002081 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2082 "vkCreateGraphicsPipelines: pararameter "
2083 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
2084 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002085 }
2086
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002087 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002088 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2089 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2090 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2091 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002092 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2093 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002094 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002095 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2096 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002097 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002098 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2099 skip |=
2100 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2101 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2102 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2103 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2104 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2105
2106 skip |= validate_array(
2107 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2108 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2109 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2110 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2111
2112 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002113 for (uint32_t vertex_binding_description_index = 0;
2114 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2115 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002116 skip |= validate_ranged_enum(
2117 "vkCreateGraphicsPipelines",
2118 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2119 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002120 pCreateInfos[i]
2121 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2122 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002123 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2124 }
2125 }
2126
2127 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002128 for (uint32_t vertex_attribute_description_index = 0;
2129 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2130 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002131 skip |= validate_ranged_enum(
2132 "vkCreateGraphicsPipelines",
2133 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2134 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002135 pCreateInfos[i]
2136 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2137 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002138 "VUID-VkVertexInputAttributeDescription-format-parameter");
2139 }
2140 }
2141
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002142 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002143 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2144 "vkCreateGraphicsPipelines: pararameter "
2145 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2146 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2147 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002148 }
2149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002150 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002151 skip |=
2152 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2153 "vkCreateGraphicsPipelines: pararameter "
2154 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2155 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2156 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002157 }
2158
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002159 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002160 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2161 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002162 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2163 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002164 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2165 "vkCreateGraphicsPipelines: parameter "
2166 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2167 "(%" PRIu32 ") is not distinct.",
2168 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002169 }
2170 vertex_bindings.insert(vertex_bind_desc.binding);
2171
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002172 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002173 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2174 "vkCreateGraphicsPipelines: parameter "
2175 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2176 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2177 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002178 }
2179
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002180 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002181 skip |=
2182 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2183 "vkCreateGraphicsPipelines: parameter "
2184 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2185 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2186 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002187 }
2188 }
2189
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002190 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002191 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2192 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002193 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2194 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002195 skip |= LogError(
2196 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002197 "vkCreateGraphicsPipelines: parameter "
2198 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2199 i, d, vertex_attrib_desc.location);
2200 }
2201 attribute_locations.insert(vertex_attrib_desc.location);
2202
2203 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2204 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002205 skip |= LogError(
2206 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002207 "vkCreateGraphicsPipelines: parameter "
2208 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2209 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2210 i, d, vertex_attrib_desc.binding, i);
2211 }
2212
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002213 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002214 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2215 "vkCreateGraphicsPipelines: parameter "
2216 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2217 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2218 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002219 }
2220
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002221 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002222 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2223 "vkCreateGraphicsPipelines: parameter "
2224 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2225 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2226 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002227 }
2228
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002229 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002230 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2231 "vkCreateGraphicsPipelines: parameter "
2232 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2233 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2234 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002235 }
2236 }
2237 }
2238
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002239 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2240 if (has_control && has_eval) {
2241 if (pCreateInfos[i].pTessellationState == nullptr) {
2242 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2243 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2244 "shader stage and a tessellation evaluation shader stage, "
2245 "pCreateInfos[%d].pTessellationState must not be NULL.",
2246 i, i);
2247 } else {
2248 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2249 skip |= validate_struct_pnext(
2250 "vkCreateGraphicsPipelines",
2251 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2252 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2253 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2254 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002255
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002256 skip |= validate_reserved_flags(
2257 "vkCreateGraphicsPipelines",
2258 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2259 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002260
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002261 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2262 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2263 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2264 "vkCreateGraphicsPipelines: invalid parameter "
2265 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2266 "should be >0 and <=%u.",
2267 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2268 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002269 }
2270 }
2271 }
2272
2273 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2274 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2275 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2276 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002277 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2278 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2279 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2280 "].pViewportState (=NULL) is not a valid pointer.",
2281 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002282 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002283 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2284
2285 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002286 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2287 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2288 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2289 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002290 }
2291
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002292 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002293 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002294 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2295 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002296 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2297 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002298 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002299 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002300 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002301 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002302 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002303 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2304 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002305 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2306 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2307 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002308 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002309
2310 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002311 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002312 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002313 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002314
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002315 auto exclusive_scissor_struct =
2316 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2317 auto shading_rate_image_struct =
2318 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2319 auto coarse_sample_order_struct =
2320 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002321 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002322 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002323 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002324 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002325
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002326 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002327 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002328 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2329 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2330 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2331 ") is not 1.",
2332 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002333 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002334
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002335 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002336 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2337 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2338 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2339 ") is not 1.",
2340 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002341 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002342
Dave Houlton142c4cb2018-10-17 15:04:41 -06002343 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2344 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002345 skip |= LogError(
2346 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2347 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2348 "disabled, but pCreateInfos[%" PRIu32
2349 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2350 ") is not 1.",
2351 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002352 }
2353
Jeff Bolz9af91c52018-09-01 21:53:57 -05002354 if (shading_rate_image_struct &&
2355 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002356 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2357 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2358 "disabled, but pCreateInfos[%" PRIu32
2359 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2360 ") is neither 0 nor 1.",
2361 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002362 }
2363
Petr Krausa6103552017-11-16 21:21:58 +01002364 } else { // multiViewport enabled
2365 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002366 if (!has_dynamic_viewport_with_count) {
2367 skip |= LogError(
2368 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2369 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2370 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002371 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002372 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2373 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2374 "].pViewportState->viewportCount (=%" PRIu32
2375 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2376 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002377 } else if (has_dynamic_viewport_with_count) {
2378 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2379 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2380 "].pViewportState->viewportCount (=%" PRIu32
2381 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2382 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002383 }
Petr Krausa6103552017-11-16 21:21:58 +01002384
2385 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002386 if (!has_dynamic_scissor_with_count) {
2387 skip |= LogError(
2388 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2389 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2390 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002391 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002392 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2393 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2394 "].pViewportState->scissorCount (=%" PRIu32
2395 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2396 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002397 } else if (has_dynamic_scissor_with_count) {
2398 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2399 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2400 "].pViewportState->scissorCount (=%" PRIu32
2401 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2402 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002403 }
2404 }
2405
ziga-lunarg845883b2021-07-14 15:05:00 +02002406 if (!has_dynamic_scissor && viewport_state.pScissors) {
2407 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2408 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002409
2410 if (scissor.offset.x < 0) {
2411 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2412 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2413 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2414 scissor.offset.x, i, scissor_i);
2415 }
2416
2417 if (scissor.offset.y < 0) {
2418 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2419 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2420 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2421 scissor.offset.y, i, scissor_i);
2422 }
2423
ziga-lunarg845883b2021-07-14 15:05:00 +02002424 const int64_t x_sum =
2425 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2426 if (x_sum > std::numeric_limits<int32_t>::max()) {
2427 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2428 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2429 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2430 "] will overflow int32_t.",
2431 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2432 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002433
ziga-lunarg845883b2021-07-14 15:05:00 +02002434 const int64_t y_sum =
2435 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2436 if (y_sum > std::numeric_limits<int32_t>::max()) {
2437 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2438 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2439 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2440 "] will overflow int32_t.",
2441 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2442 }
2443 }
2444 }
2445
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002446 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002447 skip |=
2448 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2449 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2450 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2451 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002452 }
2453
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002454 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002455 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2456 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2457 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2458 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2459 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002460 }
2461
Piers Daniell39842ee2020-07-10 16:42:33 -06002462 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2463 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002464 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2465 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2466 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2467 "].pViewportState->viewportCount (=%" PRIu32 ").",
2468 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002469 }
2470
Dave Houlton142c4cb2018-10-17 15:04:41 -06002471 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002472 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002473 skip |=
2474 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2475 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2476 ") must be zero or identical to pCreateInfos[%" PRIu32
2477 "].pViewportState->viewportCount (=%" PRIu32 ").",
2478 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002479 }
2480
Dave Houlton142c4cb2018-10-17 15:04:41 -06002481 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002482 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002483 skip |= LogError(
2484 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002485 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2486 "] "
2487 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2488 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2489 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002490 }
2491
Petr Krausa6103552017-11-16 21:21:58 +01002492 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002493 skip |= LogError(
2494 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002495 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2496 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002497 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2498 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002499 }
2500
2501 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002502 skip |= LogError(
2503 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002504 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2505 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002506 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2507 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002508 }
2509
Jeff Bolz3e71f782018-08-29 23:15:45 -05002510 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002511 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2512 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2513 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002514 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002515 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2516 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2517 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2518 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002519 }
2520
Jeff Bolz9af91c52018-09-01 21:53:57 -05002521 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002522 shading_rate_image_struct->viewportCount > 0 &&
2523 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002524 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002525 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002526 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002527 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2528 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002529 i, i);
2530 }
2531
Chris Mayer328d8212018-12-11 14:16:18 +01002532 if (vp_swizzle_struct) {
2533 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002534 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2535 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2536 " does "
2537 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2538 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002539 }
2540 }
2541
Petr Krausb3fcdb42018-01-09 22:09:09 +01002542 // validate the VkViewports
2543 if (!has_dynamic_viewport && viewport_state.pViewports) {
2544 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2545 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002546 const char *fn_name = "vkCreateGraphicsPipelines";
2547 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2548 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2549 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002550 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002551 }
2552 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002553
sfricke-samsung45996a42021-09-16 13:45:27 -07002554 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002555 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2556 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2557 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2558 "VK_NV_clip_space_w_scaling extension is not enabled.",
2559 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002560 }
2561
sfricke-samsung45996a42021-09-16 13:45:27 -07002562 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002563 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2564 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2565 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2566 "VK_EXT_discard_rectangles extension is not enabled.",
2567 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002568 }
2569
sfricke-samsung45996a42021-09-16 13:45:27 -07002570 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002571 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2572 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2573 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2574 "VK_EXT_sample_locations extension is not enabled.",
2575 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002576 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002577
sfricke-samsung45996a42021-09-16 13:45:27 -07002578 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002579 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2580 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2581 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2582 "VK_NV_scissor_exclusive extension is not enabled.",
2583 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002584 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002585
2586 if (coarse_sample_order_struct &&
2587 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2588 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002589 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2590 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2591 "] "
2592 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2593 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2594 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002595 }
2596
2597 if (coarse_sample_order_struct) {
2598 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002599 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002600 }
2601 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002602
2603 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2604 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002605 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2606 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2607 "] "
2608 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2609 ") "
2610 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2611 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002612 }
2613 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002614 skip |= LogError(
2615 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002616 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2617 "] "
2618 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2619 i);
2620 }
2621 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002622 }
2623
2624 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002625 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2626 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2627 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2628 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002629 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002630 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002631 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002632 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2633 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002634 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002635 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002636 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002637 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002638 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002639 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002640 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002641 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2642 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002643
2644 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002645 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002646 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002647 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002648
2649 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002650 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002651 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2652 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2653
2654 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002655 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002656 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2657 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002658 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002659 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002660
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002661 skip |= validate_flags(
2662 "vkCreateGraphicsPipelines",
2663 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2664 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002665 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002666
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002667 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002668 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002669 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2670 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2671
2672 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002673 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002674 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2675 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2676
2677 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002678 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002679 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2680 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2681 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002682 }
John Zulauf7acac592017-11-06 11:15:53 -07002683 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002684 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002685 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2686 "vkCreateGraphicsPipelines(): parameter "
2687 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2688 i);
John Zulauf7acac592017-11-06 11:15:53 -07002689 }
2690 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2691 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2692 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002693 skip |= LogError(
2694 device,
2695
Dave Houlton413a6782018-05-22 13:01:54 -06002696 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002697 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002698 }
2699 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002700
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002701 const auto *line_state =
2702 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002703
2704 if (line_state) {
2705 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2706 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2707 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2708 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002709 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2710 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2711 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2712 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002713 }
2714 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2715 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002716 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2717 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2718 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2719 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002720 }
2721 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2722 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002723 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2724 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2725 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2726 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002727 }
2728 }
2729 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2730 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2731 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002732 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2733 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2734 "range [1,256].",
2735 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002736 }
2737 }
2738 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002739 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002740 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2741 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002742 skip |=
2743 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2744 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2745 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2746 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002747 }
2748 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2749 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002750 skip |=
2751 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2752 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2753 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2754 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002755 }
2756 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2757 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002758 skip |=
2759 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2760 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2761 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2762 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002763 }
2764 if (line_state->stippledLineEnable) {
2765 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2766 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002767 skip |=
2768 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2769 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2770 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2771 "stippledRectangularLines feature.",
2772 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002773 }
2774 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2775 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002776 skip |=
2777 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2778 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2779 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2780 "stippledBresenhamLines feature.",
2781 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002782 }
2783 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2784 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002785 skip |=
2786 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2787 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2788 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2789 "stippledSmoothLines feature.",
2790 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002791 }
2792 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2793 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002794 skip |=
2795 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2796 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2797 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2798 "stippledRectangularLines and strictLines features.",
2799 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002800 }
2801 }
2802 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002803 }
2804
Petr Krause91f7a12017-12-14 20:57:36 +01002805 bool uses_color_attachment = false;
2806 bool uses_depthstencil_attachment = false;
2807 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002808 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002809 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2810 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002811 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002812 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002813 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002814 }
2815 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002816 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002817 }
Petr Krause91f7a12017-12-14 20:57:36 +01002818 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002819 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002820 }
2821
2822 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002823 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002824 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002825 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002826 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002827 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002828
2829 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002830 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002831 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002832 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002833
2834 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002835 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002836 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2837 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2838
2839 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002840 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002841 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2842 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2843
2844 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002845 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002846 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2847 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002848 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002849
2850 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002851 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2853 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2854
2855 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002856 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002857 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2858 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2859
2860 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002861 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002862 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2863 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002864 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002865
2866 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002867 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002868 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2869 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002870 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002871
2872 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002873 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002874 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2875 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002876 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002877
2878 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002879 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002880 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2881 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002882 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002883
2884 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002885 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002886 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2887 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002888 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002889
2890 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002891 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2893 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002894 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002895
2896 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002897 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002898 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2899 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002900 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002901
2902 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002903 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002904 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2905 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002906 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002907
2908 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002909 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002910 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2911 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2912 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002913 }
2914 }
2915
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002916 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02002917 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
2918 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002919
Petr Krause91f7a12017-12-14 20:57:36 +01002920 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002921 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2922 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2923 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2924 pCreateInfos[i].pColorBlendState,
2925 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2926 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2927
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002928 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002929 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002930 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
ziga-lunarg8de09162021-08-05 15:21:33 +02002931 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002932 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2933 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002934 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2935 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002936
2937 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002938 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002939 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002940 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002941
2942 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002943 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2945 pCreateInfos[i].pColorBlendState->logicOpEnable);
2946
2947 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002948 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002949 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2950 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002951 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002952 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953
2954 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002955 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2956 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002957 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002959 ParameterName::IndexVector{i, attachment_index}),
2960 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002961
2962 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002963 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002965 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002966 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002967 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002968 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002969
2970 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002971 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002972 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002973 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002974 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002975 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002976 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002977
2978 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002979 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002980 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002981 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002982 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002983 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002984 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002985
2986 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002987 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002988 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002989 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002990 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002991 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002992 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002993
2994 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002995 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002996 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002997 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002998 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002999 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003000 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003001
3002 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003003 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003004 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003005 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003006 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003007 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003008 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003009
3010 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003011 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003012 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003013 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003014 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003015 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003016 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003017
3018 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3019 bool invalid = false;
3020 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3021 case VK_BLEND_OP_ZERO_EXT:
3022 case VK_BLEND_OP_SRC_EXT:
3023 case VK_BLEND_OP_DST_EXT:
3024 case VK_BLEND_OP_SRC_OVER_EXT:
3025 case VK_BLEND_OP_DST_OVER_EXT:
3026 case VK_BLEND_OP_SRC_IN_EXT:
3027 case VK_BLEND_OP_DST_IN_EXT:
3028 case VK_BLEND_OP_SRC_OUT_EXT:
3029 case VK_BLEND_OP_DST_OUT_EXT:
3030 case VK_BLEND_OP_SRC_ATOP_EXT:
3031 case VK_BLEND_OP_DST_ATOP_EXT:
3032 case VK_BLEND_OP_XOR_EXT:
3033 case VK_BLEND_OP_INVERT_EXT:
3034 case VK_BLEND_OP_INVERT_RGB_EXT:
3035 case VK_BLEND_OP_LINEARDODGE_EXT:
3036 case VK_BLEND_OP_LINEARBURN_EXT:
3037 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3038 case VK_BLEND_OP_LINEARLIGHT_EXT:
3039 case VK_BLEND_OP_PINLIGHT_EXT:
3040 case VK_BLEND_OP_HARDMIX_EXT:
3041 case VK_BLEND_OP_PLUS_EXT:
3042 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3043 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3044 case VK_BLEND_OP_PLUS_DARKER_EXT:
3045 case VK_BLEND_OP_MINUS_EXT:
3046 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3047 case VK_BLEND_OP_CONTRAST_EXT:
3048 case VK_BLEND_OP_INVERT_OVG_EXT:
3049 case VK_BLEND_OP_RED_EXT:
3050 case VK_BLEND_OP_GREEN_EXT:
3051 case VK_BLEND_OP_BLUE_EXT:
3052 invalid = true;
3053 break;
3054 default:
3055 break;
3056 }
3057 if (invalid) {
3058 skip |= LogError(
3059 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3060 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3061 "].pColorBlendState->pAttachments[%" PRIu32
3062 "].colorBlendOp (%s) is not valid when "
3063 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3064 "VK_FALSE",
3065 i, attachment_index,
3066 string_VkBlendOp(
3067 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3068 }
3069 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003070 }
3071 }
3072
3073 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003074 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003075 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
3076 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3077 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003078 }
3079
3080 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3081 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3082 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003083 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003084 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003085 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3086 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003087 }
3088 }
3089 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003090
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003091 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3092 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003093 if (pCreateInfos[i].basePipelineIndex != -1) {
3094 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003095 skip |=
3096 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003097 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003098 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003099 "and pCreateInfos->basePipelineIndex is not -1.",
3100 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003101 }
3102 }
3103
Petr Kraus9752aae2017-11-24 03:05:50 +01003104 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3105 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003106 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003107 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003108 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003109 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3110 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003111 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003112 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003113 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003114 skip |=
3115 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
3116 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
3117 "index into the pCreateInfos array, of size %d.",
3118 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003119 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003120 }
3121 }
3122
Petr Kraus9752aae2017-11-24 03:05:50 +01003123 if (pCreateInfos[i].pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003124 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003125 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3126 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003127 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3128 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3129 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3130 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003131 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3132 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003133 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003134 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003135 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
3136 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3137 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003138 }
3139 } else {
3140 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3141 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3142 (physical_device_features.fillModeNonSolid == false)) {
3143 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003144 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3145 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003146 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
3147 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3148 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003149 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003150 }
Petr Kraus299ba622017-11-24 03:09:03 +01003151
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003152 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003153 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003154 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3155 "The line width state is static (pCreateInfos[%" PRIu32
3156 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3157 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3158 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3159 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003160 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003161 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003162
3163 // Validate no flags not allowed are used
3164 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003165 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
3166 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3167 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3168 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003169 }
3170 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003171 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
3172 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3173 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3174 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003175 }
3176 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3177 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07003178 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3179 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3180 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003181 }
3182 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3183 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07003184 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3185 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3186 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003187 }
3188 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3189 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07003190 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3191 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3192 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003193 }
3194 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3195 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003196 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3197 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3198 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003199 }
3200 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3201 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003202 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3203 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3204 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003205 }
3206 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3207 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003208 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3209 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3210 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003211 }
3212 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3213 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003214 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3215 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3216 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003217 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003218 }
3219 }
3220
3221 return skip;
3222}
3223
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003224bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3225 uint32_t createInfoCount,
3226 const VkComputePipelineCreateInfo *pCreateInfos,
3227 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003228 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003229 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003230 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003231 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003232 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003233 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003234 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003235 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003236 skip |=
3237 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3238 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3239 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3240 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003241 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003242
3243 // Make sure compute stage is selected
3244 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003245 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3246 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3247 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003248 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003249
sfricke-samsungeb549012021-04-16 01:25:51 -07003250 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3251 // Validate no flags not allowed are used
3252 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3253 skip |= LogError(
3254 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3255 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3256 i, flags);
3257 }
3258 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3259 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3260 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3261 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3262 i, flags);
3263 }
3264 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3265 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3266 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3267 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3268 i, flags);
3269 }
3270 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3271 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3272 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3273 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3274 i, flags);
3275 }
3276 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3277 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3278 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3279 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3280 i, flags);
3281 }
3282 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3283 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3284 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3285 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3286 i, flags);
3287 }
3288 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3289 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3290 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3291 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3292 i, flags);
3293 }
3294 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3295 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3296 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3297 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3298 i, flags);
3299 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003300 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3301 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
3302 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3303 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3304 i, flags);
3305 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003306 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3307 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3308 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3309 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3310 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003311 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003312 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3313 if (pCreateInfos[i].basePipelineIndex != -1) {
3314 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3315 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3316 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3317 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3318 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3319 i);
3320 }
3321 }
3322
3323 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3324 if (pCreateInfos[i].basePipelineIndex != -1) {
3325 skip |= LogError(
3326 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3327 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3328 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3329 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3330 i);
3331 }
3332 } else {
3333 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3334 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3335 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3336 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3337 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3338 }
3339 }
3340 }
ziga-lunargc6341372021-07-28 12:57:42 +02003341
3342 std::stringstream msg;
3343 msg << "pCreateInfos[%" << i << "].stage";
3344 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003345 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003346 return skip;
3347}
3348
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003349bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003350 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003351 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003352
3353 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003354 const auto &features = physical_device_features;
3355 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003356
John Zulauf71968502017-10-26 13:51:15 -06003357 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3358 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003359 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3360 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3361 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3362 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003363 }
3364
3365 // Anistropy cannot be enabled in sampler unless enabled as a feature
3366 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003367 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3368 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3369 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003370 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003371 }
John Zulauf71968502017-10-26 13:51:15 -06003372
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003373 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3374 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003375 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3376 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3377 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3378 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003379 }
3380 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003381 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3382 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3383 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3384 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003385 }
3386 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003387 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3388 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3389 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3390 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003391 }
3392 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3393 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3394 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3395 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003396 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3397 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3398 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3399 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3400 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3401 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003402 }
3403 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003404 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3405 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3406 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003407 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003408 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003409 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3410 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3411 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003412 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003413 }
3414
3415 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3416 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003417 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3418 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003419 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003420 if (sampler_reduction != nullptr) {
3421 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3422 skip |= LogError(
3423 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3424 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3425 }
3426 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003427 }
3428
3429 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3430 // valid VkBorderColor value
3431 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3432 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3433 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003434 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3435 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003436 }
3437
John Zulauf275805c2017-10-26 15:34:49 -06003438 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003439 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003440 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3441 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003442 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3443 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3444 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003445 }
3446 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003447
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003448 // Check for valid Lod range
3449 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003450 skip |=
3451 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3452 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003453 }
3454
3455 // Check mipLodBias to device limit
3456 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003457 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3458 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3459 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003460 }
3461
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003462 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003463 if (sampler_conversion != nullptr) {
3464 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3465 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3466 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3467 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003468 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003469 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003470 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3471 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3472 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3473 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3474 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3475 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3476 }
3477 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003478
3479 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3480 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3481 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3482 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3483 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3484 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3485 }
3486 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3487 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3488 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3489 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3490 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3491 }
3492 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3493 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3494 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3495 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3496 pCreateInfo->minLod, pCreateInfo->maxLod);
3497 }
3498 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3499 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3500 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3501 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3502 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3503 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3504 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3505 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3506 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3507 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3508 }
3509 if (pCreateInfo->anisotropyEnable) {
3510 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3511 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3512 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3513 }
3514 if (pCreateInfo->compareEnable) {
3515 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3516 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3517 "pCreateInfo->compareEnable must be VK_FALSE");
3518 }
3519 if (pCreateInfo->unnormalizedCoordinates) {
3520 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3521 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3522 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3523 }
3524 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003525 }
3526
Tony-LunarG7337b312020-04-15 16:40:25 -06003527 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3528 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003529 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
Tony-LunarG7337b312020-04-15 16:40:25 -06003530 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3531 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3532 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3533 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003534 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003535 if (!custom_create_info) {
3536 skip |=
3537 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3538 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3539 "struct in pNext chain.\n",
3540 string_VkBorderColor(pCreateInfo->borderColor));
3541 } else {
3542 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3543 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3544 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3545 !FormatIsSampledFloat(custom_create_info->format)))) {
3546 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3547 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3548 "whose type does not match\n",
3549 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3550 ;
3551 }
3552 }
3553 }
3554
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003555 return skip;
3556}
3557
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003558bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3559 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3560 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003561 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003562 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003563
3564 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3565 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3566 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3567 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003568 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3569 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3570 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3571 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3572 ++descriptor_index) {
3573 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003574 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003575 "vkCreateDescriptorSetLayout: required parameter "
3576 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3577 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003578 }
3579 }
3580 }
3581
3582 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3583 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3584 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003585 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3586 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3587 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3588 "values.",
3589 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003590 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003591
3592 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3593 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3594 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3595 skip |=
3596 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3597 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3598 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3599 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3600 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3601 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003602 }
3603 }
3604 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003605 return skip;
3606}
3607
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003608bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3609 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003610 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003611 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3612 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3613 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003614 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3615 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003616}
3617
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003618bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3619 const VkWriteDescriptorSet *pDescriptorWrites,
3620 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003621 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003622
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003623 if (pDescriptorWrites != NULL) {
3624 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3625 // descriptorCount must be greater than 0
3626 if (pDescriptorWrites[i].descriptorCount == 0) {
3627 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003628 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3629 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003630 }
3631
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003632 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3633 if (validateDstSet) {
3634 // dstSet must be a valid VkDescriptorSet handle
3635 skip |= validate_required_handle(vkCallingFunction,
3636 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3637 pDescriptorWrites[i].dstSet);
3638 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003639
3640 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3641 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3642 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3643 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3644 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3645 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3646 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003647 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3648 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003649 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003650 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3651 "%s(): if pDescriptorWrites[%d].descriptorType is "
3652 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3653 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3654 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3655 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003656 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3657 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003658 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3659 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003660 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3661 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003662 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003663 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3664 ParameterName::IndexVector{i, descriptor_index}),
3665 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003666 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003667 }
3668 }
3669 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3670 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3671 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3672 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3673 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3674 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3675 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003676 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003677 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003678 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3679 "%s(): if pDescriptorWrites[%d].descriptorType is "
3680 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3681 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3682 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3683 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003684 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003685 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003686 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003687 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003688 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3689 ++descriptor_index) {
3690 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3691 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3692 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003693 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3694 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003695 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003696 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3697 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003698 }
3699 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003700 }
3701 }
3702 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3703 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003704 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003705 }
3706
3707 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3708 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003709 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003710 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3711 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003712 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003713 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003714 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3715 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3716 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003717 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003718 }
3719 }
3720 }
3721 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3722 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003723 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003724 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3725 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003726 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003727 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003728 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3729 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3730 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003731 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003732 }
3733 }
3734 }
3735 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003736 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3737 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003738 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003739 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003740 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3741 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3742 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3743 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3744 "accelerationStructureCount %d member equals descriptorCount %d.",
3745 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3746 pDescriptorWrites[i].descriptorCount);
3747 }
3748 // further checks only if we have right structtype
3749 if (pnext_struct) {
3750 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3751 skip |= LogError(
3752 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3753 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3754 ".",
3755 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003756 }
sourav parmarbcee7512020-12-28 14:34:49 -08003757 if (pnext_struct->accelerationStructureCount == 0) {
3758 skip |= LogError(device,
3759 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003760 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003761 }
3762 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003763 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003764 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3765 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3766 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3767 skip |= LogError(device,
3768 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3769 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003770 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003771 }
3772 }
3773 }
sourav parmarbcee7512020-12-28 14:34:49 -08003774 }
3775 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003776 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003777 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3778 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3779 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3780 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3781 "accelerationStructureCount %d member equals descriptorCount %d.",
3782 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3783 pDescriptorWrites[i].descriptorCount);
3784 }
3785 // further checks only if we have right structtype
3786 if (pnext_struct) {
3787 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3788 skip |= LogError(
3789 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3790 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3791 ".",
3792 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003793 }
sourav parmarbcee7512020-12-28 14:34:49 -08003794 if (pnext_struct->accelerationStructureCount == 0) {
3795 skip |= LogError(device,
3796 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003797 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003798 }
3799 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003800 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003801 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3802 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3803 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3804 skip |= LogError(device,
3805 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3806 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003807 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003808 }
3809 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003810 }
3811 }
3812 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003813 }
3814 }
3815 return skip;
3816}
3817
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003818bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3819 const VkWriteDescriptorSet *pDescriptorWrites,
3820 uint32_t descriptorCopyCount,
3821 const VkCopyDescriptorSet *pDescriptorCopies) const {
3822 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3823}
3824
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003825bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003826 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003827 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003828 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3829}
3830
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003831bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3832 const VkAllocationCallbacks *pAllocator,
3833 VkRenderPass *pRenderPass) const {
3834 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3835}
3836
Mike Schuchardt2df08912020-12-15 16:28:09 -08003837bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003838 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003839 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003840 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3841}
3842
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003843bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3844 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003845 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003846 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003847
3848 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3849 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3850 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003851 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3852 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003853 return skip;
3854}
3855
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003856bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003857 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003858 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003859
3860 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3861 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003862 bool cb_is_secondary;
3863 {
3864 auto lock = cb_read_lock();
3865 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3866 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003867
Tony-LunarG3c287f62020-12-17 12:39:49 -07003868 if (cb_is_secondary) {
3869 // Implicit VUs
3870 // validate only sType here; pointer has to be validated in core_validation
3871 const bool k_not_required = false;
3872 const char *k_no_vuid = nullptr;
3873 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3874 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003875 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3876 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003877
Tony-LunarG3c287f62020-12-17 12:39:49 -07003878 if (info) {
3879 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003880 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3881 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003882 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003883 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3884 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3885 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3886 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003887
Tony-LunarG3c287f62020-12-17 12:39:49 -07003888 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003889
Tony-LunarG3c287f62020-12-17 12:39:49 -07003890 // Explicit VUs
3891 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003892 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003893 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3894 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3895 cmd_name);
3896 }
3897
3898 if (physical_device_features.inheritedQueries) {
3899 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003900 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3901 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3902 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003903 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003904 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003905 }
3906
3907 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003908 skip |=
3909 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3910 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3911 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3912 } else { // !pipelineStatisticsQuery
3913 skip |=
3914 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3915 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003916 }
3917
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003918 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003919 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003920 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003921 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3922 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3923 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003924 commandBuffer,
3925 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003926 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3927 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3928 }
Petr Kraus139757b2019-08-15 17:19:33 +02003929 }
ziga-lunarg9d019132021-07-19 01:05:31 +02003930
3931 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
3932 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
3933 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
3934 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
3935 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
3936 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
3937 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
3938 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
3939 }
Petr Kraus139757b2019-08-15 17:19:33 +02003940 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003941 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003942 return skip;
3943}
3944
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003945bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003946 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003947 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003948
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003949 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003950 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003951 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3952 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3953 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003954 }
3955 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003956 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3957 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3958 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003959 }
3960 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003961 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003962 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003963 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3964 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3965 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3966 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003967 }
3968 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003969
3970 if (pViewports) {
3971 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3972 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003973 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003974 skip |= manual_PreCallValidateViewport(
3975 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003976 }
3977 }
3978
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003979 return skip;
3980}
3981
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003982bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003983 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003984 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003985
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003986 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003987 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003988 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3989 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3990 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003991 }
3992 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003993 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3994 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3995 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003996 }
3997 } else { // multiViewport enabled
3998 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003999 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004000 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4001 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4002 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4003 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004004 }
4005 }
4006
Petr Kraus6260f0a2018-02-27 21:15:55 +01004007 if (pScissors) {
4008 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4009 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004010
Petr Kraus6260f0a2018-02-27 21:15:55 +01004011 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004012 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4013 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4014 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004015 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004016
Petr Kraus6260f0a2018-02-27 21:15:55 +01004017 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004018 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4019 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4020 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004021 }
4022
4023 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4024 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004025 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4026 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4027 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4028 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004029 }
4030
4031 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4032 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004033 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4034 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4035 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4036 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004037 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004038 }
4039 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004040
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004041 return skip;
4042}
4043
Jeff Bolz5c801d12019-10-09 10:38:45 -05004044bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004045 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004046
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004047 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004048 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4049 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004050 }
4051
4052 return skip;
4053}
4054
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004055bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004056 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004057 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004058
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004059 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004060 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004061 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
4062 }
4063 if (drawCount > device_limits.maxDrawIndirectCount) {
4064 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004065 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
4066 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004067 }
4068 return skip;
4069}
4070
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004071bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004072 VkDeviceSize offset, uint32_t drawCount,
4073 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004074 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004075 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004076 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4077 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
4078 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004079 }
4080 if (drawCount > device_limits.maxDrawIndirectCount) {
4081 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004082 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4083 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004084 }
4085 return skip;
4086}
4087
sfricke-samsungf692b972020-05-02 08:00:45 -07004088bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4089 VkDeviceSize countBufferOffset, bool khr) const {
4090 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004091 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004092 if (offset & 3) {
4093 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004094 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004095 }
4096
4097 if (countBufferOffset & 3) {
4098 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004099 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004100 countBufferOffset);
4101 }
4102 return skip;
4103}
4104
4105bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4106 VkDeviceSize offset, VkBuffer countBuffer,
4107 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4108 uint32_t stride) const {
4109 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4110}
4111
4112bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4113 VkDeviceSize offset, VkBuffer countBuffer,
4114 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4115 uint32_t stride) const {
4116 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4117}
4118
4119bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4120 VkDeviceSize countBufferOffset, bool khr) const {
4121 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004122 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004123 if (offset & 3) {
4124 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004125 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004126 }
4127
4128 if (countBufferOffset & 3) {
4129 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004130 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004131 countBufferOffset);
4132 }
4133 return skip;
4134}
4135
4136bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4137 VkDeviceSize offset, VkBuffer countBuffer,
4138 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4139 uint32_t stride) const {
4140 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4141}
4142
4143bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4144 VkDeviceSize offset, VkBuffer countBuffer,
4145 VkDeviceSize countBufferOffset,
4146 uint32_t maxDrawCount, uint32_t stride) const {
4147 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4148}
4149
Tony-LunarG4490de42021-06-21 15:49:19 -06004150bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4151 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4152 uint32_t firstInstance, uint32_t stride) const {
4153 bool skip = false;
4154 if (stride & 3) {
4155 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4156 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4157 }
4158 if (drawCount && nullptr == pVertexInfo) {
4159 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4160 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4161 "one or more valid instances of VkMultiDrawInfoEXT structures");
4162 }
4163 return skip;
4164}
4165
4166bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4167 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4168 uint32_t instanceCount, uint32_t firstInstance,
4169 uint32_t stride, const int32_t *pVertexOffset) const {
4170 bool skip = false;
4171 if (stride & 3) {
4172 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4173 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4174 }
4175 if (drawCount && nullptr == pIndexInfo) {
4176 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4177 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4178 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4179 }
4180 return skip;
4181}
4182
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004183bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4184 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004185 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004186 bool skip = false;
4187 for (uint32_t rect = 0; rect < rectCount; rect++) {
4188 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004189 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
4190 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004191 }
sfricke-samsung10867682020-04-25 02:20:39 -07004192 if (pRects[rect].rect.extent.width == 0) {
4193 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
4194 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
4195 }
4196 if (pRects[rect].rect.extent.height == 0) {
4197 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
4198 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
4199 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004200 }
4201 return skip;
4202}
4203
Andrew Fobel3abeb992020-01-20 16:33:22 -05004204bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4205 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4206 VkImageFormatProperties2 *pImageFormatProperties,
4207 const char *apiName) const {
4208 bool skip = false;
4209
4210 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004211 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004212 if (image_stencil_struct != nullptr) {
4213 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4214 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4215 // No flags other than the legal attachment bits may be set
4216 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4217 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004218 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4219 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4220 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4221 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4222 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004223 }
4224 }
4225 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004226 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4227 if (image_drm_format) {
4228 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4229 skip |= LogError(
4230 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4231 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4232 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4233 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4234 }
4235 } else {
4236 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4237 skip |= LogError(
4238 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4239 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4240 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4241 apiName);
4242 }
4243 }
4244 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4245 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4246 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4247 if (!format_list || format_list->viewFormatCount == 0) {
4248 skip |= LogError(
4249 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4250 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4251 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4252 apiName);
4253 }
4254 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004255 }
4256
4257 return skip;
4258}
4259
4260bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4261 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4262 VkImageFormatProperties2 *pImageFormatProperties) const {
4263 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4264 "vkGetPhysicalDeviceImageFormatProperties2");
4265}
4266
4267bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4268 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4269 VkImageFormatProperties2 *pImageFormatProperties) const {
4270 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4271 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4272}
4273
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004274bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4275 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4276 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4277 bool skip = false;
4278
4279 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4280 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4281 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4282 }
4283
4284 return skip;
4285}
4286
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004287bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4288 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4289 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4290 bool skip = false;
4291
4292 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4293 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4294 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4295 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4296 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4297 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4298 }
4299
ziga-lunarg42f884b2021-08-25 16:13:20 +02004300 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004301}
4302
sfricke-samsung3999ef62020-02-09 17:05:59 -08004303bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4304 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4305 bool skip = false;
4306
4307 if (pRegions != nullptr) {
4308 for (uint32_t i = 0; i < regionCount; i++) {
4309 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004310 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4311 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004312 }
4313 }
4314 }
4315 return skip;
4316}
4317
Jeff Leger178b1e52020-10-05 12:22:23 -04004318bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4319 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4320 bool skip = false;
4321
4322 if (pCopyBufferInfo->pRegions != nullptr) {
4323 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4324 if (pCopyBufferInfo->pRegions[i].size == 0) {
4325 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4326 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4327 }
4328 }
4329 }
4330 return skip;
4331}
4332
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004333bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004334 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4335 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004336 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004337
4338 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004339 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4340 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4341 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004342 }
4343
4344 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004345 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4346 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4347 "), must be greater than zero and less than or equal to 65536.",
4348 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004349 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004350 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4351 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4352 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004353 }
4354 return skip;
4355}
4356
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004357bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004358 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004359 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004360
4361 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004362 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4363 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4364 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004365 }
4366
4367 if (size != VK_WHOLE_SIZE) {
4368 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004369 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004370 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4371 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004372 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004373 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4374 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004375 }
4376 }
4377 return skip;
4378}
4379
sfricke-samsunga1d00272021-03-10 21:37:41 -08004380bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004381 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004382
4383 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004384 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4385 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4386 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4387 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004388 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004389 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4390 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4391 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004392 }
4393
4394 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4395 // queueFamilyIndexCount uint32_t values
4396 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004397 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004398 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004399 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004400 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4401 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004402 }
4403 }
4404
Dave Houlton413a6782018-05-22 13:01:54 -06004405 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004406 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004407
sfricke-samsunga1d00272021-03-10 21:37:41 -08004408 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4409 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4410 if (format_list_info) {
4411 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4412 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4413 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4414 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4415 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4416 func_name, viewFormatCount);
4417 }
4418
4419 // Using the first format, compare the rest of the formats against it that they are compatible
4420 for (uint32_t i = 1; i < viewFormatCount; i++) {
4421 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4422 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4423 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4424 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4425 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4426 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4427 string_VkFormat(format_list_info->pViewFormats[i]));
4428 }
4429 }
4430 }
4431
4432 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4433 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4434 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4435 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4436 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4437 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4438 func_name);
4439 } else {
4440 if (format_list_info == nullptr) {
4441 skip |= LogError(
4442 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4443 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4444 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4445 func_name);
4446 } else if (format_list_info->viewFormatCount == 0) {
4447 skip |= LogError(
4448 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4449 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4450 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4451 func_name);
4452 } else {
4453 bool found_base_format = false;
4454 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4455 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4456 found_base_format = true;
4457 break;
4458 }
4459 }
4460 if (!found_base_format) {
4461 skip |=
4462 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4463 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4464 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4465 "pCreateInfo->imageFormat.",
4466 func_name);
4467 }
4468 }
4469 }
4470 }
4471 }
4472 return skip;
4473}
4474
4475bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4476 const VkAllocationCallbacks *pAllocator,
4477 VkSwapchainKHR *pSwapchain) const {
4478 bool skip = false;
4479 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4480 return skip;
4481}
4482
4483bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4484 const VkSwapchainCreateInfoKHR *pCreateInfos,
4485 const VkAllocationCallbacks *pAllocator,
4486 VkSwapchainKHR *pSwapchains) const {
4487 bool skip = false;
4488 if (pCreateInfos) {
4489 for (uint32_t i = 0; i < swapchainCount; i++) {
4490 std::stringstream func_name;
4491 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4492 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4493 }
4494 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004495 return skip;
4496}
4497
Jeff Bolz5c801d12019-10-09 10:38:45 -05004498bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004499 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004500
4501 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004502 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004503 if (present_regions) {
4504 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004505 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004506 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4507 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004508 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004509 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4510 "extension swapchainCount is %i. These values must be equal.",
4511 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004512 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004513 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004514 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4515 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004516 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4517 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4518 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004519 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004520 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004521 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004522 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004523 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004524 }
4525 }
4526
4527 return skip;
4528}
4529
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004530bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4531 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4532 const VkAllocationCallbacks *pAllocator,
4533 VkDisplayModeKHR *pMode) const {
4534 bool skip = false;
4535
4536 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4537 if (display_mode_parameters.visibleRegion.width == 0) {
4538 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4539 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4540 }
4541 if (display_mode_parameters.visibleRegion.height == 0) {
4542 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4543 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4544 }
4545 if (display_mode_parameters.refreshRate == 0) {
4546 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4547 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4548 }
4549
4550 return skip;
4551}
4552
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004553#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004554bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4555 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4556 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004557 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004558 bool skip = false;
4559
4560 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004561 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4562 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004563 }
4564
4565 return skip;
4566}
4567#endif // VK_USE_PLATFORM_WIN32_KHR
4568
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004569bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004570 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004571 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004572 bool skip = false;
4573
4574 if (pCreateInfo) {
4575 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004576 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4577 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004578 }
4579
4580 if (pCreateInfo->pPoolSizes) {
4581 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4582 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004583 skip |= LogError(
4584 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004585 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004586 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004587 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4588 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004589 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4590 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4591 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4592 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4593 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004594 }
Petr Krausc8655be2017-09-27 18:56:51 +02004595 }
4596 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004597
4598 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4599 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4600 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4601 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4602 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4603 }
Petr Krausc8655be2017-09-27 18:56:51 +02004604 }
4605
4606 return skip;
4607}
4608
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004609bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004610 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004611 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004612
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004613 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004614 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004615 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4616 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4617 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004618 }
4619
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004620 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004621 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004622 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4623 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4624 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004625 }
4626
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004627 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004628 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004629 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4630 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4631 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004632 }
4633
4634 return skip;
4635}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004636
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004637bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004638 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004639 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004640
4641 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004642 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4643 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004644 }
4645 return skip;
4646}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004647
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004648bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4649 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004650 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004651 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004652
4653 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004654 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004655 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004656 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4657 "vkCmdDispatch(): baseGroupX (%" PRIu32
4658 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4659 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004660 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004661 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4662 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4663 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4664 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004665 }
4666
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004667 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004668 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004669 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4670 "vkCmdDispatch(): baseGroupY (%" PRIu32
4671 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4672 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004673 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004674 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4675 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4676 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4677 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004678 }
4679
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004680 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004681 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004682 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4683 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4684 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4685 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004686 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004687 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4688 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4689 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4690 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004691 }
4692
4693 return skip;
4694}
4695
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004696bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4697 VkPipelineBindPoint pipelineBindPoint,
4698 VkPipelineLayout layout, uint32_t set,
4699 uint32_t descriptorWriteCount,
4700 const VkWriteDescriptorSet *pDescriptorWrites) const {
4701 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4702}
4703
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004704bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4705 uint32_t firstExclusiveScissor,
4706 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004707 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004708 bool skip = false;
4709
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004710 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004711 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004712 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004713 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4714 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4715 ") is not 0.",
4716 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004717 }
4718 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004719 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004720 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4721 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4722 ") is not 1.",
4723 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004724 }
4725 } else { // multiViewport enabled
4726 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004727 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004728 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4729 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4730 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4731 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004732 }
4733 }
4734
Jeff Bolz3e71f782018-08-29 23:15:45 -05004735 if (pExclusiveScissors) {
4736 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4737 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4738
4739 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004740 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4741 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4742 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004743 }
4744
4745 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004746 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4747 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4748 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004749 }
4750
4751 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4752 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004753 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4754 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4755 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4756 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004757 }
4758
4759 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4760 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004761 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4762 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4763 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4764 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004765 }
4766 }
4767 }
4768
4769 return skip;
4770}
4771
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004772bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4773 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004774 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004775 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004776 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4777 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4778 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4779 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4780 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4781 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004782 }
4783
4784 return skip;
4785}
4786
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004787bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4788 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004789 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004790 bool skip = false;
4791
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004792 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004793 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004794 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004795 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4796 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4797 ") is not 0.",
4798 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004799 }
4800 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004801 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004802 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4803 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4804 ") is not 1.",
4805 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004806 }
4807 }
4808
Jeff Bolz9af91c52018-09-01 21:53:57 -05004809 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004810 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004811 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4812 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4813 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4814 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004815 }
4816
4817 return skip;
4818}
4819
Jeff Bolz5c801d12019-10-09 10:38:45 -05004820bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4821 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4822 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004823 bool skip = false;
4824
Dave Houlton142c4cb2018-10-17 15:04:41 -06004825 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004826 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4827 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4828 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004829 }
4830
4831 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004832 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004833 }
4834
4835 return skip;
4836}
4837
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004838bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004839 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004840 bool skip = false;
4841
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004842 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004843 skip |= LogError(
4844 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004845 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4846 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004847 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004848 }
4849
4850 return skip;
4851}
4852
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004853bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4854 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004855 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004856 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004857 static const int condition_multiples = 0b0011;
4858 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004859 skip |= LogError(
4860 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004861 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004862 }
Lockee1c22882019-06-10 16:02:54 -06004863 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004864 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4865 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4866 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4867 stride);
Lockee1c22882019-06-10 16:02:54 -06004868 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004869 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004870 skip |= LogError(
4871 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4872 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004873 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004874 if (drawCount > device_limits.maxDrawIndirectCount) {
4875 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004876 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4877 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004878 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004879 return skip;
4880}
4881
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004882bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4883 VkDeviceSize offset, VkBuffer countBuffer,
4884 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004885 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004886 bool skip = false;
4887
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004888 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004889 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4890 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4891 "), is not a multiple of 4.",
4892 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004893 }
4894
4895 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004896 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4897 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4898 "), is not a multiple of 4.",
4899 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004900 }
4901
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004902 return skip;
4903}
4904
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004905bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004906 const VkAllocationCallbacks *pAllocator,
4907 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004908 bool skip = false;
4909
4910 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4911 if (pCreateInfo != nullptr) {
4912 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4913 // VkQueryPipelineStatisticFlagBits values
4914 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4915 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004916 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4917 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4918 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4919 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004920 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004921 if (pCreateInfo->queryCount == 0) {
4922 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4923 "vkCreateQueryPool(): queryCount must be greater than zero.");
4924 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004925 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004926 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004927}
4928
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004929bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4930 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004931 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004932 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4933 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004934}
4935
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004936void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004937 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4938 VkResult result) {
4939 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004940 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004941}
4942
Mike Schuchardt2df08912020-12-15 16:28:09 -08004943void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004944 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4945 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004946 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004947 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004948 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004949}
4950
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004951void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4952 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004953 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004954 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004955 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004956}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004957
Tony-LunarG3c287f62020-12-17 12:39:49 -07004958void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004959 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004960 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4961 auto lock = cb_write_lock();
4962 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004963 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004964 }
4965 }
4966}
4967
4968void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004969 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004970 auto lock = cb_write_lock();
4971 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4972 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4973 }
4974}
4975
4976void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004977 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004978 auto lock = cb_write_lock();
4979 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4980 if (item->second == commandPool) {
4981 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004982 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004983 ++item;
4984 }
4985 }
4986}
4987
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004988bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004989 const VkAllocationCallbacks *pAllocator,
4990 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004991 bool skip = false;
4992
4993 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004994 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004995 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004996 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4997 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004998 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004999
5000 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005001 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005002 if (flags_info) {
5003 flags = flags_info->flags;
5004 }
5005
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005006 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005007 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005008 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005009 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5010 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005011 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005012 }
5013
5014#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005015 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005016#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005017 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5018 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005019#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005020 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005021#endif
5022
5023 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005024 skip |= LogError(
5025 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005026 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5027 }
5028 if (
5029#ifdef VK_USE_PLATFORM_WIN32_KHR
5030 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5031#endif
5032 (import_memory_fd && import_memory_fd->handleType) ||
5033#ifdef VK_USE_PLATFORM_ANDROID_KHR
5034 (import_memory_ahb && import_memory_ahb->buffer) ||
5035#endif
5036 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005037 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5038 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005039 }
5040 }
5041
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005042 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5043 if (export_memory) {
5044 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5045 if (export_memory_nv) {
5046 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5047 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5048 "VkExportMemoryAllocateInfoNV");
5049 }
5050#ifdef VK_USE_PLATFORM_WIN32_KHR
5051 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5052 if (export_memory_win32_nv) {
5053 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5054 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5055 "VkExportMemoryWin32HandleInfoNV");
5056 }
5057#endif
5058 }
5059
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005060 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005061 VkBool32 capture_replay = false;
5062 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005063 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005064 if (vulkan_12_features) {
5065 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5066 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5067 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005068 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005069 if (bda_features) {
5070 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5071 buffer_device_address = bda_features->bufferDeviceAddress;
5072 }
5073 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005074 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005075 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005076 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005077 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005078 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005079 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005080 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005081 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005082 }
5083 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005084 }
5085 return skip;
5086}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005087
Jason Macnak192fa0e2019-07-26 15:07:16 -07005088bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005089 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005090 bool skip = false;
5091
5092 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5093 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5094 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005095 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005096 } else {
5097 uint32_t vertex_component_size = 0;
5098 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5099 vertex_component_size = 4;
5100 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5101 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5102 vertex_component_size = 2;
5103 }
5104 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005105 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005106 }
5107 }
5108
5109 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5110 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005111 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005112 } else {
5113 uint32_t index_element_size = 0;
5114 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5115 index_element_size = 4;
5116 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5117 index_element_size = 2;
5118 }
5119 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005120 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005121 }
5122 }
5123 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5124 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005125 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005126 }
5127 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005128 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005129 }
5130 }
5131
5132 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005133 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005134 }
5135
5136 return skip;
5137}
5138
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005139bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5140 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005141 bool skip = false;
5142
5143 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005144 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005145 }
5146 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005147 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005148 }
5149
5150 return skip;
5151}
5152
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005153bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5154 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005155 bool skip = false;
5156 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005157 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005158 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005159 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005160 }
5161 return skip;
5162}
5163
5164bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005165 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005166 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005167 bool skip = false;
5168 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005169 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5170 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5171 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005172 }
5173 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005174 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5175 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5176 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005177 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005178 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5179 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5180 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5181 }
Jason Macnak5c954952019-07-09 15:46:12 -07005182 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5183 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005184 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5185 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5186 "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 -07005187 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005188 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005189 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005190 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5191 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005192 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5193 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005194 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005195 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005196 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5197 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5198 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005199 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005200 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005201 uint64_t total_triangle_count = 0;
5202 for (uint32_t i = 0; i < info.geometryCount; i++) {
5203 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005204
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005205 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005206
Jason Macnak5c954952019-07-09 15:46:12 -07005207 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5208 continue;
5209 }
5210 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5211 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005212 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005213 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5214 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5215 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005216 }
5217 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005218 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5219 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5220 for (uint32_t i = 1; i < info.geometryCount; i++) {
5221 const VkGeometryNV &geometry = info.pGeometries[i];
5222 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005223 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005224 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
5225 "info.pGeometries[0].geometryType.",
5226 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005227 }
5228 }
5229 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005230 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5231 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5232 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5233 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5234 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5235 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5236 }
5237 }
5238 skip |=
5239 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005240 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005241 return skip;
5242}
5243
Ricardo Garciaa4935972019-02-21 17:43:18 +01005244bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5245 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005246 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005247 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005248 if (pCreateInfo) {
5249 if ((pCreateInfo->compactedSize != 0) &&
5250 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005251 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5252 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5253 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5254 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005255 }
Jason Macnak5c954952019-07-09 15:46:12 -07005256
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005257 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005258 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005259 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005260 return skip;
5261}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005262
Jeff Bolz5c801d12019-10-09 10:38:45 -05005263bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5264 const VkAccelerationStructureInfoNV *pInfo,
5265 VkBuffer instanceData, VkDeviceSize instanceOffset,
5266 VkBool32 update, VkAccelerationStructureNV dst,
5267 VkAccelerationStructureNV src, VkBuffer scratch,
5268 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005269 bool skip = false;
5270
5271 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005272 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005273 }
5274
5275 return skip;
5276}
5277
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005278bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5279 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5280 VkAccelerationStructureKHR *pAccelerationStructure) const {
5281 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005282 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005283 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005284 if (!acceleration_structure_features ||
5285 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5286 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5287 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5288 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005289 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005290 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5291 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005292 (acceleration_structure_features &&
5293 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005294 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005295 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5296 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5297 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5298 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005299 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005300 if (pCreateInfo->deviceAddress &&
5301 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5302 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5303 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5304 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5305 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005306 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5307 (acceleration_structure_features &&
5308 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5309 skip |= LogError(
5310 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5311 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5312 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5313 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005314 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5315 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005316 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5317 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005318 }
sourav parmar83c31b12020-05-06 12:30:54 -07005319 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005320 return skip;
5321}
5322
Jason Macnak5c954952019-07-09 15:46:12 -07005323bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5324 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005325 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005326 bool skip = false;
5327 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005328 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5329 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005330 }
5331 return skip;
5332}
5333
sourav parmarcd5fb182020-07-17 12:58:44 -07005334bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5335 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5336 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5337 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005338 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005339 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005340 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005341 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005342 }
5343 return skip;
5344}
5345
Peter Chen85366392019-05-14 15:20:11 -04005346bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5347 uint32_t createInfoCount,
5348 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5349 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005350 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005351 bool skip = false;
5352
5353 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005354 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5355 std::stringstream msg;
5356 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5357 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5358 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005359 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005360 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005361 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005362 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5363 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5364 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5365 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005366 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005367
5368 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005369 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005370 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5371 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5372 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5373 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5374 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5375 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5376 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5377 }
5378 }
5379
sourav parmarf4a78252020-04-10 13:04:21 -07005380 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5381 skip |=
5382 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5383 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5384 }
5385 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5386 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5387 skip |=
5388 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5389 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5390 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5391 }
5392 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5393 if (pCreateInfos[i].basePipelineIndex != -1) {
5394 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5395 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5396 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5397 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5398 "and pCreateInfos->basePipelineIndex is not -1.");
5399 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005400 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005401 skip |=
5402 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5403 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5404 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5405 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5406 "that element.");
5407 }
sourav parmarf4a78252020-04-10 13:04:21 -07005408 }
5409 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005410 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005411 skip |=
5412 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5413 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5414 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5415 "commands pCreateInfos parameter.");
5416 }
5417 } else {
5418 if (pCreateInfos[i].basePipelineIndex != -1) {
5419 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5420 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5421 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5422 }
5423 }
5424 }
5425 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5426 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5427 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5428 }
5429 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5430 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5431 "vkCreateRayTracingPipelinesNV: flags must not include "
5432 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5433 }
5434 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5435 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5436 "vkCreateRayTracingPipelinesNV: flags must not include "
5437 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5438 }
5439 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5440 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5441 "vkCreateRayTracingPipelinesNV: flags must not include "
5442 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5443 }
5444 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5445 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5446 "vkCreateRayTracingPipelinesNV: flags must not include "
5447 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5448 }
5449 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5450 skip |= LogError(
5451 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5452 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5453 }
5454 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5455 skip |= LogError(
5456 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5457 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5458 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005459 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5460 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5461 "vkCreateRayTracingPipelinesNV: flags must not include "
5462 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5463 }
5464 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5465 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5466 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5467 }
Peter Chen85366392019-05-14 15:20:11 -04005468 }
5469
5470 return skip;
5471}
5472
sourav parmarcd5fb182020-07-17 12:58:44 -07005473bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5474 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5475 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005476 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005477 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005478 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5479 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5480 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005481 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005482 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005483 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5484 std::stringstream msg;
5485 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5486 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5487 &pCreateInfos[i].pStages[i]);
5488 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005489 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5490 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5491 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5492 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5493 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5494 }
5495 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5496 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5497 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5498 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5499 }
5500 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005501 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005502 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5503 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005504 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5505 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5506 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005507 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5508 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5509 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005510 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005511 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005512 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5513 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5514 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5515 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005516 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005517 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5518 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5519 }
5520 }
sourav parmarf4a78252020-04-10 13:04:21 -07005521 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005522 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5523 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005524 }
5525 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005526 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005527 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005528 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5529 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005530 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005531 }
5532 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5533 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5534 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005535 }
5536 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5537 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5538 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5539 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5540 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5541 skip |= LogError(
5542 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005543 "vkCreateRayTracingPipelinesKHR: If flags includes "
5544 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005545 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5546 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5547 "must not be VK_SHADER_UNUSED_KHR");
5548 }
5549 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5550 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5551 skip |= LogError(
5552 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005553 "vkCreateRayTracingPipelinesKHR: If flags includes "
5554 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005555 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5556 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5557 "element must not be VK_SHADER_UNUSED_KHR");
5558 }
5559 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005560 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5561 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5562 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5563 skip |= LogError(
5564 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5565 "vkCreateRayTracingPipelinesKHR: If "
5566 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5567 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5568 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5569 }
5570 }
sourav parmarf4a78252020-04-10 13:04:21 -07005571 }
5572 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5573 if (pCreateInfos[i].basePipelineIndex != -1) {
5574 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5575 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005576 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005577 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5578 "and pCreateInfos->basePipelineIndex is not -1.");
5579 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005580 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005581 skip |=
5582 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5583 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5584 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5585 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5586 "element.");
5587 }
sourav parmarf4a78252020-04-10 13:04:21 -07005588 }
5589 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005590 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005591 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005592 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005593 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5594 "commands pCreateInfos parameter %d.",
5595 pCreateInfos[i].basePipelineIndex, createInfoCount);
5596 }
5597 } else {
5598 if (pCreateInfos[i].basePipelineIndex != -1) {
5599 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005600 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005601 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5602 }
5603 }
5604 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005605 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5606 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5607 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5608 "vkCreateRayTracingPipelinesKHR: If flags includes "
5609 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5610 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005611 }
5612 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5613 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5614 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5615 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5616 "pLibraryInfo and pLibraryInterface must be NULL.");
5617 }
5618 if (pCreateInfos[i].pLibraryInfo) {
5619 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5620 if (pCreateInfos[i].stageCount == 0) {
5621 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5622 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5623 "stageCount must not be 0.");
5624 }
5625 if (pCreateInfos[i].groupCount == 0) {
5626 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5627 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5628 "groupCount must not be 0.");
5629 }
5630 } else {
5631 if (pCreateInfos[i].pLibraryInterface == NULL) {
5632 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5633 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5634 "is greater than 0, its "
5635 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005636 }
5637 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005638 }
5639 if (pCreateInfos[i].pLibraryInterface) {
5640 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5641 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5642 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5643 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5644 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5645 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005646 }
5647 if (deferredOperation != VK_NULL_HANDLE) {
5648 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5649 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5650 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5651 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005652 }
5653 }
ziga-lunargdea76582021-09-17 14:38:08 +02005654 if (pCreateInfos[i].pDynamicState) {
5655 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
5656 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
5657 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
5658 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
5659 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
5660 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
5661 }
5662 }
5663 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005664 }
5665
5666 return skip;
5667}
5668
Mike Schuchardt21638df2019-03-16 10:52:02 -07005669#ifdef VK_USE_PLATFORM_WIN32_KHR
5670bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5671 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005672 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005673 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07005674 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005675 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005676 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005677 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005678 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005679 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005680 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005681 skip |=
5682 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07005683 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07005684 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5685 skip |= validate_struct_type(
5686 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5687 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5688 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5689 if (pSurfaceInfo != NULL) {
5690 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5691 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5692 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5693
5694 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5695 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5696 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5697 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005698 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5699 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005700
5701 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5702 }
5703 return skip;
5704}
5705#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005706
5707bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5708 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005709 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005710 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5711 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005712 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005713 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5714 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5715 }
5716 return skip;
5717}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005718
5719bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005720 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005721 bool skip = false;
5722
5723 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005724 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5725 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005726 }
5727
5728 return skip;
5729}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005730
5731bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005732 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005733 bool skip = false;
5734
5735 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005736 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5737 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005738 }
5739
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005740 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005741 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005742 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5743 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005744 }
5745
5746 return skip;
5747}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005748
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005749bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5750 uint32_t bindingCount, const VkBuffer *pBuffers,
5751 const VkDeviceSize *pOffsets) const {
5752 bool skip = false;
5753 if (firstBinding > device_limits.maxVertexInputBindings) {
5754 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5755 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5756 device_limits.maxVertexInputBindings);
5757 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5758 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5759 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5760 "maxVertexInputBindings (%u)",
5761 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5762 }
5763
Jeff Bolz165818a2020-05-08 11:19:03 -05005764 for (uint32_t i = 0; i < bindingCount; ++i) {
5765 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005766 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005767 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5768 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5769 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5770 } else {
5771 if (pOffsets[i] != 0) {
5772 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5773 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5774 }
5775 }
5776 }
5777 }
5778
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005779 return skip;
5780}
5781
Mark Lobodzinski84988402019-09-11 15:27:30 -06005782bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005783 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005784 bool skip = false;
5785 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005786 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5787 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005788 }
5789 return skip;
5790}
5791
5792bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005793 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005794 bool skip = false;
5795 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005796 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5797 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005798 }
5799 return skip;
5800}
Petr Kraus3d720392019-11-13 02:52:39 +01005801
5802bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5803 VkSemaphore semaphore, VkFence fence,
5804 uint32_t *pImageIndex) const {
5805 bool skip = false;
5806
5807 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005808 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5809 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005810 }
5811
5812 return skip;
5813}
5814
5815bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5816 uint32_t *pImageIndex) const {
5817 bool skip = false;
5818
5819 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005820 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5821 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005822 }
5823
5824 return skip;
5825}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005826
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005827bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5828 uint32_t firstBinding, uint32_t bindingCount,
5829 const VkBuffer *pBuffers,
5830 const VkDeviceSize *pOffsets,
5831 const VkDeviceSize *pSizes) const {
5832 bool skip = false;
5833
5834 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5835 for (uint32_t i = 0; i < bindingCount; ++i) {
5836 if (pOffsets[i] & 3) {
5837 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5838 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5839 }
5840 }
5841
5842 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5843 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5844 "%s: The firstBinding(%" PRIu32
5845 ") index is greater than or equal to "
5846 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5847 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5848 }
5849
5850 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5851 skip |=
5852 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5853 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5854 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5855 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5856 }
5857
5858 for (uint32_t i = 0; i < bindingCount; ++i) {
5859 // pSizes is optional and may be nullptr.
5860 if (pSizes != nullptr) {
5861 if (pSizes[i] != VK_WHOLE_SIZE &&
5862 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5863 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5864 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5865 ") is not VK_WHOLE_SIZE and is greater than "
5866 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5867 cmd_name, i, pSizes[i]);
5868 }
5869 }
5870 }
5871
5872 return skip;
5873}
5874
5875bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5876 uint32_t firstCounterBuffer,
5877 uint32_t counterBufferCount,
5878 const VkBuffer *pCounterBuffers,
5879 const VkDeviceSize *pCounterBufferOffsets) const {
5880 bool skip = false;
5881
5882 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5883 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5884 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5885 "%s: The firstCounterBuffer(%" PRIu32
5886 ") index is greater than or equal to "
5887 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5888 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5889 }
5890
5891 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5892 skip |=
5893 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5894 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5895 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5896 cmd_name, firstCounterBuffer, counterBufferCount,
5897 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5898 }
5899
5900 return skip;
5901}
5902
5903bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5904 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5905 const VkBuffer *pCounterBuffers,
5906 const VkDeviceSize *pCounterBufferOffsets) const {
5907 bool skip = false;
5908
5909 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5910 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5911 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5912 "%s: The firstCounterBuffer(%" PRIu32
5913 ") index is greater than or equal to "
5914 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5915 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5916 }
5917
5918 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5919 skip |=
5920 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5921 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5922 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5923 cmd_name, firstCounterBuffer, counterBufferCount,
5924 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5925 }
5926
5927 return skip;
5928}
5929
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005930bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5931 uint32_t firstInstance, VkBuffer counterBuffer,
5932 VkDeviceSize counterBufferOffset,
5933 uint32_t counterOffset, uint32_t vertexStride) const {
5934 bool skip = false;
5935
5936 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005937 skip |= LogError(
5938 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005939 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5940 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5941 }
5942
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005943 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005944 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005945 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005946 }
5947
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005948 return skip;
5949}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005950
5951bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5952 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5953 const VkAllocationCallbacks *pAllocator,
5954 VkSamplerYcbcrConversion *pYcbcrConversion,
5955 const char *apiName) const {
5956 bool skip = false;
5957
5958 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005959 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005960 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005961 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005962 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5963 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005964 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005965 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005966 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005967
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005968#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005969 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005970 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005971#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005972 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005973#endif
5974
sfricke-samsung1a72f942020-07-25 12:09:18 -07005975 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005976
5977 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005978 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005979 const VkComponentMapping components = pCreateInfo->components;
5980 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5981 if (FormatIsXChromaSubsampled(format) == true) {
5982 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5983 skip |=
5984 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005985 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5986 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005987 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005988 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005989
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005990 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5991 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5992 skip |= LogError(
5993 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5994 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5995 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5996 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5997 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005998
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005999 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6000 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6001 skip |=
6002 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006003 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6004 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006005 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006006 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006007
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006008 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6009 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6010 skip |=
6011 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006012 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6013 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006014 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006015 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006016
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006017 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006018 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6019 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6020 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006021 skip |=
6022 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006023 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6024 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006025 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6026 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006027 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006028 }
6029
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006030 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6031 // Checks same VU multiple ways in order to give a more useful error message
6032 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6033 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6034 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6035 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6036 skip |= LogError(
6037 device, vuid,
6038 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6039 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6040 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6041 string_VkComponentSwizzle(components.b));
6042 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006043
sfricke-samsunged028b02021-09-06 23:14:51 -07006044 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6045 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006046 // 3 = no [a]
6047 // 2 = no [b,a]
6048 // 1 = no [g,b,a]
6049 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006050 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006051
sfricke-samsunged028b02021-09-06 23:14:51 -07006052 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6053 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006054 skip |= LogError(device, vuid,
6055 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6056 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6057 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6058 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006059 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006060 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6061 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6062 skip |= LogError(device, vuid,
6063 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6064 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6065 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6066 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6067 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006068 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006069 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6070 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6071 skip |= LogError(device, vuid,
6072 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6073 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6074 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6075 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6076 string_VkComponentSwizzle(components.b));
6077 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006078 }
6079 }
6080
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006081 return skip;
6082}
6083
6084bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6085 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6086 const VkAllocationCallbacks *pAllocator,
6087 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6088 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6089 "vkCreateSamplerYcbcrConversion");
6090}
6091
6092bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6093 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6094 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6095 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6096 "vkCreateSamplerYcbcrConversionKHR");
6097}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006098
6099bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6100 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6101 bool skip = false;
6102 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6103 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6104
6105 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006106 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6107 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6108 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6109 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6110 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006111 }
6112 return skip;
6113}
sourav parmara96ab1a2020-04-25 16:28:23 -07006114
6115bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006116 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006117 bool skip = false;
6118 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6119 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6120 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6121 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006122 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006123 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6124 skip |= LogError(
6125 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6126 "vkCopyAccelerationStructureToMemoryKHR: The "
6127 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6128 }
6129 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6130 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6131 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6132 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6133 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6134 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006135 return skip;
6136}
6137
6138bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6139 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6140 bool skip = false;
6141 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6142 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6143 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6144 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6145 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006146 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6147 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006148 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006149 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006150 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006151 return skip;
6152}
6153
6154bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6155 const char *api_name) const {
6156 bool skip = false;
6157 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6158 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6159 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6160 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6161 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6162 api_name);
6163 }
6164 return skip;
6165}
6166
6167bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006168 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006169 bool skip = false;
6170 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006171 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006172 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006173 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006174 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6175 "vkCopyAccelerationStructureKHR: The "
6176 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006177 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006178 return skip;
6179}
6180
6181bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6182 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6183 bool skip = false;
6184 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6185 return skip;
6186}
6187
6188bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006189 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006190 bool skip = false;
6191 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006192 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006193 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6194 }
6195 return skip;
6196}
6197
6198bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006199 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006200 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006201 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006202 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006203 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6204 skip |= LogError(
6205 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6206 "vkCopyMemoryToAccelerationStructureKHR: The "
6207 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006208 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006209 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6210 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006211 return skip;
6212}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006213
sourav parmara96ab1a2020-04-25 16:28:23 -07006214bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6215 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6216 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006217 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006218 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6219 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006220 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006221 pInfo->src.deviceAddress);
6222 }
sourav parmar83c31b12020-05-06 12:30:54 -07006223 return skip;
6224}
6225bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6226 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6227 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6228 bool skip = false;
6229 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6230 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6231 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6232 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6233 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6234 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6235 }
6236 return skip;
6237}
6238bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6239 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6240 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6241 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006242 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006243 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6244 skip |= LogError(
6245 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6246 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6247 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6248 }
sourav parmar83c31b12020-05-06 12:30:54 -07006249 if (dataSize < accelerationStructureCount * stride) {
6250 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6251 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
6252 "accelerationStructureCount (%d) *stride(%zu).",
6253 dataSize, accelerationStructureCount, stride);
6254 }
6255 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6256 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6257 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6258 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6259 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6260 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6261 }
6262 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6263 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6264 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6265 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6266 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6267 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6268 stride);
6269 }
6270 }
6271 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6272 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6273 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6274 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6275 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6276 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6277 stride);
6278 }
6279 }
sourav parmar83c31b12020-05-06 12:30:54 -07006280 return skip;
6281}
6282bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6283 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6284 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006285 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006286 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6287 skip |= LogError(
6288 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6289 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6290 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006291 }
6292 return skip;
6293}
6294
6295bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006296 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6297 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6298 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6299 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006300 uint32_t width, uint32_t height, uint32_t depth) const {
6301 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006302 // RayGen
6303 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6304 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6305 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006306 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006307 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6308 0) {
6309 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6310 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6311 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6312 }
6313 // Callable
6314 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6315 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6316 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6317 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006318 }
6319 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6320 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6321 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006322 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6323 }
6324 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6325 0) {
6326 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6327 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6328 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006329 }
6330 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006331 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6332 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6333 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6334 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006335 }
6336 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6337 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006338 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6339 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006340 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006341 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6342 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6343 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6344 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6345 }
sourav parmar83c31b12020-05-06 12:30:54 -07006346 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006347 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6348 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6349 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6350 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006351 }
6352 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6353 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6354 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006355 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6356 }
6357 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6358 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6359 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6360 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6361 }
6362 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6363 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6364 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6365 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6366 }
6367 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6368 skip |=
6369 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6370 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6371 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006372 }
6373
sourav parmarcd5fb182020-07-17 12:58:44 -07006374 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6375 skip |=
6376 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6377 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6378 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6379 }
6380
6381 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6382 skip |=
6383 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6384 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6385 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006386 }
6387 return skip;
6388}
6389
sourav parmarcd5fb182020-07-17 12:58:44 -07006390bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6391 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6392 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6393 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006394 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006395 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006396 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6397 skip |= LogError(
6398 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6399 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6400 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006401 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006402 // RayGen
6403 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6404 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6405 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006406 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006407 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6408 0) {
6409 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6410 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6411 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6412 }
6413 // Callabe
6414 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6415 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6416 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6417 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006418 }
6419 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6420 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006421 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6422 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6423 }
6424 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6425 0) {
6426 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6427 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6428 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006429 }
6430 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006431 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6432 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6433 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6434 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006435 }
6436 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6437 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006438 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6439 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006440 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006441 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6442 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6443 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6444 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6445 }
sourav parmar83c31b12020-05-06 12:30:54 -07006446 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006447 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6448 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6449 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6450 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006451 }
6452 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6453 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006454 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6455 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6456 }
6457 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6458 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6459 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6460 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006461 }
6462
sourav parmarcd5fb182020-07-17 12:58:44 -07006463 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6464 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6465 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006466 }
6467 return skip;
6468}
6469bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6470 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6471 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6472 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6473 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6474 uint32_t width, uint32_t height, uint32_t depth) const {
6475 bool skip = false;
6476 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6477 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6478 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6479 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6480 }
6481 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6482 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6483 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6484 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6485 }
6486 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6487 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6488 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6489 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6490 }
6491
6492 // hitShader
6493 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6494 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6495 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6496 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6497 }
6498 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6499 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6500 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6501 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6502 }
6503 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6504 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6505 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6506 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6507 }
6508
6509 // missShader
6510 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6511 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6512 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6513 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6514 }
6515 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6516 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6517 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6518 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6519 }
6520 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6521 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6522 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6523 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6524 }
6525
6526 // raygenShader
6527 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6528 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6529 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006530 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6531 }
6532 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6533 skip |=
6534 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6535 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6536 }
6537 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6538 skip |=
6539 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6540 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6541 }
6542 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6543 skip |=
6544 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6545 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006546 }
6547 return skip;
6548}
6549
sourav parmar83c31b12020-05-06 12:30:54 -07006550bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006551 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6552 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006553 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006554 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6555 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006556 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6557 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006558 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006559 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6560 }
6561 return skip;
6562}
6563
Piers Daniell39842ee2020-07-10 16:42:33 -06006564bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6565 const VkViewport *pViewports) const {
6566 bool skip = false;
6567
6568 if (!physical_device_features.multiViewport) {
6569 if (viewportCount != 1) {
6570 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6571 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6572 ") is not 1.",
6573 viewportCount);
6574 }
6575 } else { // multiViewport enabled
6576 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6577 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6578 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6579 ") must "
6580 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6581 viewportCount, device_limits.maxViewports);
6582 }
6583 }
6584
6585 if (pViewports) {
6586 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6587 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6588 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6589 skip |= manual_PreCallValidateViewport(
6590 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6591 }
6592 }
6593
6594 return skip;
6595}
6596
6597bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6598 const VkRect2D *pScissors) const {
6599 bool skip = false;
6600
6601 if (!physical_device_features.multiViewport) {
6602 if (scissorCount != 1) {
6603 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6604 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6605 ") must "
6606 "be 1 when the multiViewport feature is disabled.",
6607 scissorCount);
6608 }
6609 } else { // multiViewport enabled
6610 if (scissorCount == 0) {
6611 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6612 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6613 ") must "
6614 "be great than zero.",
6615 scissorCount);
6616 } else if (scissorCount > device_limits.maxViewports) {
6617 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6618 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6619 ") must "
6620 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6621 scissorCount, device_limits.maxViewports);
6622 }
6623 }
6624
6625 if (pScissors) {
6626 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6627 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6628
6629 if (scissor.offset.x < 0) {
6630 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6631 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6632 scissor.offset.x);
6633 }
6634
6635 if (scissor.offset.y < 0) {
6636 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6637 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6638 scissor.offset.y);
6639 }
6640
6641 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6642 if (x_sum > INT32_MAX) {
6643 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6644 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6645 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6646 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6647 }
6648
6649 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6650 if (y_sum > INT32_MAX) {
6651 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6652 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6653 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6654 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6655 }
6656 }
6657 }
6658
6659 return skip;
6660}
6661
6662bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6663 uint32_t bindingCount, const VkBuffer *pBuffers,
6664 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6665 const VkDeviceSize *pStrides) const {
6666 bool skip = false;
6667 if (firstBinding >= device_limits.maxVertexInputBindings) {
6668 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6669 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6670 firstBinding, device_limits.maxVertexInputBindings);
6671 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6672 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6673 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6674 "maxVertexInputBindings (%u)",
6675 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6676 }
6677
6678 for (uint32_t i = 0; i < bindingCount; ++i) {
6679 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006680 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006681 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6682 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6683 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6684 } else {
6685 if (pOffsets[i] != 0) {
6686 skip |=
6687 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6688 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6689 }
6690 }
6691 }
6692 if (pStrides) {
6693 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6694 skip |=
6695 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006696 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i,
Piers Daniell39842ee2020-07-10 16:42:33 -06006697 pStrides[i], device_limits.maxVertexInputBindingStride);
6698 }
6699 }
6700 }
6701
6702 return skip;
6703}
sourav parmarcd5fb182020-07-17 12:58:44 -07006704
6705bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6706 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6707 bool skip = false;
6708 for (uint32_t i = 0; i < infoCount; ++i) {
6709 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6710 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6711 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6712 }
6713 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6714 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6715 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6716 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6717 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6718 api_name);
6719 }
6720 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6721 skip |=
6722 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6723 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6724 }
6725 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6726 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6727 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6728 }
6729 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6730 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6731 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6732 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6733 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6734 api_name);
6735 }
6736 if (pInfos[i].pGeometries) {
6737 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6738 skip |= validate_ranged_enum(
6739 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6740 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6741 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6742 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006743 skip |= validate_struct_type(
6744 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6745 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6746 &(pInfos[i].pGeometries[j].geometry.triangles),
6747 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6748 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6749 skip |= validate_struct_pnext(
6750 api_name,
6751 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6752 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6753 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6754 skip |=
6755 validate_ranged_enum(api_name,
6756 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6757 ParameterName::IndexVector{i, j}),
6758 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6759 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6760 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6761 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6762 &pInfos[i].pGeometries[j].geometry.triangles,
6763 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6764 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6765 skip |= validate_ranged_enum(
6766 api_name,
6767 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6768 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6769 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6770
6771 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6772 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6773 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6774 }
6775 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6776 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6777 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6778 skip |=
6779 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6780 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6781 api_name);
6782 }
6783 }
6784 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6785 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6786 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6787 &pInfos[i].pGeometries[j].geometry.instances,
6788 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6789 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6790 skip |= validate_struct_type(
6791 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6792 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6793 &(pInfos[i].pGeometries[j].geometry.instances),
6794 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6795 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6796 skip |= validate_struct_pnext(
6797 api_name,
6798 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6799 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6800 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6801
6802 skip |= validate_bool32(api_name,
6803 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6804 ParameterName::IndexVector{i, j}),
6805 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6806 }
6807 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6808 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6809 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6810 &pInfos[i].pGeometries[j].geometry.aabbs,
6811 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6812 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6813 skip |= validate_struct_type(
6814 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6815 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6816 &(pInfos[i].pGeometries[j].geometry.aabbs),
6817 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6818 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6819 skip |= validate_struct_pnext(
6820 api_name,
6821 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6822 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6823 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6824 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6825 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6826 "(%s):stride must be less than or equal to 2^32-1", api_name);
6827 }
6828 }
6829 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6830 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6831 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6832 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6833 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6834 api_name);
6835 }
6836 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6837 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6838 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6839 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6840 "of elements of"
6841 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6842 api_name);
6843 }
6844 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6845 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6846 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6847 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6848 api_name);
6849 }
6850 }
6851 }
6852 }
6853 if (pInfos[i].ppGeometries != NULL) {
6854 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6855 skip |= validate_ranged_enum(
6856 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6857 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6858 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6859 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006860 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6861 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6862 &pInfos[i].ppGeometries[j]->geometry.triangles,
6863 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6864 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6865 skip |= validate_struct_type(
6866 api_name,
6867 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6868 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6869 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6870 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6871 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6872 skip |= validate_struct_pnext(
6873 api_name,
6874 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6875 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6876 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6877 skip |= validate_ranged_enum(api_name,
6878 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6879 ParameterName::IndexVector{i, j}),
6880 "VkFormat", AllVkFormatEnums,
6881 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6882 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6883 skip |= validate_ranged_enum(api_name,
6884 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6885 ParameterName::IndexVector{i, j}),
6886 "VkIndexType", AllVkIndexTypeEnums,
6887 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6888 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6889 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6890 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6891 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6892 }
6893 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6894 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6895 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6896 skip |=
6897 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6898 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6899 api_name);
6900 }
6901 }
6902 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6903 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6904 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6905 &pInfos[i].ppGeometries[j]->geometry.instances,
6906 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6907 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6908 skip |= validate_struct_type(
6909 api_name,
6910 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6911 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6912 &(pInfos[i].ppGeometries[j]->geometry.instances),
6913 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6914 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6915 skip |= validate_struct_pnext(
6916 api_name,
6917 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6918 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6919 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6920 skip |= validate_bool32(api_name,
6921 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6922 ParameterName::IndexVector{i, j}),
6923 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6924 }
6925 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6926 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6927 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6928 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6929 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6930 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6931 skip |= validate_struct_type(
6932 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6933 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6934 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6935 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6936 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6937 skip |= validate_struct_pnext(
6938 api_name,
6939 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6940 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6941 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6942 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6943 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6944 "(%s):stride must be less than or equal to 2^32-1", api_name);
6945 }
6946 }
6947 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6948 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6949 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6950 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6951 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6952 api_name);
6953 }
6954 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6955 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6956 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6957 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6958 "of elements of"
6959 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6960 api_name);
6961 }
6962 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6963 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6964 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6965 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6966 api_name);
6967 }
6968 }
6969 }
6970 }
6971 }
6972 return skip;
6973}
6974bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6975 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6976 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6977 bool skip = false;
6978 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6979 for (uint32_t i = 0; i < infoCount; ++i) {
6980 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6981 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6982 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6983 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6984 "scratchData.deviceAddress member must be a multiple of "
6985 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6986 }
6987 for (uint32_t k = 0; k < infoCount; ++k) {
6988 if (i == k) continue;
6989 bool found = false;
6990 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6991 skip |= LogError(
6992 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6993 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6994 "not be "
6995 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6996 i, k);
6997 found = true;
6998 }
6999 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
7000 skip |= LogError(
7001 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7002 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
7003 "not be "
7004 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7005 i, k);
7006 found = true;
7007 }
7008 if (found) break;
7009 }
7010 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7011 if (pInfos[i].pGeometries) {
7012 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7013 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7014 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7015 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7016 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7017 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7018 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7019 }
7020 } else {
7021 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7022 skip |=
7023 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7024 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7025 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7026 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7027 }
7028 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007029 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007030 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7031 skip |= LogError(
7032 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7033 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7034 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7035 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007036 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7037 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007038 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7039 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7040 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7041 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7042 }
7043 }
7044 } else if (pInfos[i].ppGeometries) {
7045 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7046 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7047 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7048 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7049 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7050 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7051 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7052 }
7053 } else {
7054 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7055 skip |=
7056 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7057 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7058 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7059 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7060 }
7061 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007062 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007063 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7064 skip |= LogError(
7065 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7066 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7067 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7068 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007069 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7070 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007071 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7072 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7073 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7074 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7075 }
7076 }
7077 }
7078 }
7079 }
7080 return skip;
7081}
7082
7083bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7084 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7085 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7086 const uint32_t *const *ppMaxPrimitiveCounts) const {
7087 bool skip = false;
7088 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7089 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007090 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007091 if (!ray_tracing_acceleration_structure_features ||
7092 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7093 skip |= LogError(
7094 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7095 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7096 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7097 }
7098 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007099 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7100 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7101 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7102 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7103 "scratchData.deviceAddress member must be a multiple of "
7104 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7105 }
7106 for (uint32_t k = 0; k < infoCount; ++k) {
7107 if (i == k) continue;
7108 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
7109 skip |=
7110 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7111 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
7112 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7113 "any other element [%d) of pInfos.",
7114 i, k);
7115 break;
7116 }
7117 }
7118 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7119 if (pInfos[i].pGeometries) {
7120 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7121 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7122 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7123 skip |= LogError(
7124 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7125 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7126 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7127 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7128 }
7129 } else {
7130 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7131 skip |= LogError(
7132 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7133 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7134 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7135 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7136 }
7137 }
7138 }
7139 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7140 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7141 skip |= LogError(
7142 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7143 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7144 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7145 }
7146 }
7147 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7148 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7149 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7150 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7151 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7152 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7153 }
7154 }
7155 } else if (pInfos[i].ppGeometries) {
7156 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7157 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7158 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7159 skip |= LogError(
7160 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7161 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7162 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7163 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7164 }
7165 } else {
7166 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7167 skip |= LogError(
7168 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7169 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7170 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7171 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7172 }
7173 }
7174 }
7175 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7176 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7177 skip |= LogError(
7178 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7179 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7180 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7181 }
7182 }
7183 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7184 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7185 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7186 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7187 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7188 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7189 }
7190 }
7191 }
7192 }
7193 }
7194 return skip;
7195}
7196
7197bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7198 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7199 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7200 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7201 bool skip = false;
7202 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7203 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007204 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007205 if (!ray_tracing_acceleration_structure_features ||
7206 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7207 skip |=
7208 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7209 "vkBuildAccelerationStructuresKHR: The "
7210 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7211 }
7212 for (uint32_t i = 0; i < infoCount; ++i) {
7213 for (uint32_t j = 0; j < infoCount; ++j) {
7214 if (i == j) continue;
7215 bool found = false;
7216 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7217 skip |= LogError(
7218 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7219 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
7220 "not be "
7221 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7222 i, j);
7223 found = true;
7224 }
7225 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7226 skip |= LogError(
7227 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7228 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
7229 "not be "
7230 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7231 i, j);
7232 found = true;
7233 }
7234 if (found) break;
7235 }
7236 }
7237 return skip;
7238}
7239
7240bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7241 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7242 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7243 bool skip = false;
7244 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7245 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007246 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7247 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007248 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7249 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7250 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7251 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7252 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7253 }
7254 return skip;
7255}
sfricke-samsungecafb192021-01-17 08:21:14 -08007256
7257bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7258 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7259 const VkAllocationCallbacks *pAllocator,
7260 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7261 bool skip = false;
7262 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7263 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7264 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7265 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7266 }
7267 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007268}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007269
7270bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7271 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7272 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7273 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7274 bool skip = false;
7275 const auto *vertex_input_dynamic_state_features =
7276 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7277 const auto *vertex_attribute_divisor_features =
7278 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7279
7280 // VUID-vkCmdSetVertexInputEXT-None-04790
7281 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7282 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7283 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7284 }
7285
7286 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7287 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7288 skip |=
7289 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7290 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7291 }
7292
7293 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7294 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7295 skip |= LogError(
7296 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7297 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7298 }
7299
7300 // VUID-vkCmdSetVertexInputEXT-binding-04793
7301 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7302 bool binding_found = false;
7303 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7304 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7305 binding_found = true;
7306 break;
7307 }
7308 }
7309 if (!binding_found) {
7310 skip |=
7311 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7312 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
7313 }
7314 }
7315
7316 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7317 if (vertexBindingDescriptionCount > 1) {
7318 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7319 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7320 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7321 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7322 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
7323 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
7324 }
7325 }
7326 }
7327 }
7328
7329 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7330 if (vertexAttributeDescriptionCount > 1) {
7331 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7332 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7333 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7334 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7335 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
7336 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
7337 }
7338 }
7339 }
7340 }
7341
7342 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7343 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7344 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
7345 skip |= LogError(
7346 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7347 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
7348 }
7349
7350 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7351 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
7352 skip |= LogError(
7353 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7354 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
7355 binding);
7356 }
7357
7358 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7359 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7360 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7361 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7362 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7363 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7364 binding);
7365 }
7366
7367 if (pVertexBindingDescriptions[binding].divisor > 1) {
7368 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7369 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7370 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7371 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7372 "vertexAttributeInstanceRateDivisor is not enabled",
7373 binding);
7374 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007375 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007376 if (pVertexBindingDescriptions[binding].divisor >
7377 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7378 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007379 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007380 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7381 binding);
7382 }
7383
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007384 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007385 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7386 skip |=
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007387 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007388 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7389 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7390 binding);
7391 }
7392 }
7393 }
7394 }
7395
7396 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007397 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007398 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7399 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007400 device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007401 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7402 attribute);
7403 }
7404
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007405 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007406 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7407 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007408 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007409 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7410 attribute);
7411 }
7412
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007413 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007414 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7415 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007416 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007417 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7418 attribute);
7419 }
7420
7421 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7422 VkFormatProperties properties;
7423 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7424 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7425 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7426 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7427 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7428 attribute);
7429 }
7430 }
7431
7432 return skip;
7433}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007434
7435bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7436 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7437 const void *pValues) const {
7438 bool skip = false;
7439 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7440 // Check that offset + size don't exceed the max.
7441 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7442 if (offset >= max_push_constants_size) {
7443 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7444 "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset,
7445 max_push_constants_size);
7446 }
7447 if (size > max_push_constants_size - offset) {
7448 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
7449 "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.",
7450 offset, size, max_push_constants_size);
7451 }
7452
7453 // size needs to be non-zero and a multiple of 4.
7454 if (size & 0x3) {
7455 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.",
7456 size);
7457 }
7458
7459 // offset needs to be a multiple of 4.
7460 if ((offset & 0x3) != 0) {
7461 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007462 "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007463 }
7464 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007465}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007466
7467bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7468 uint32_t srcCacheCount,
7469 const VkPipelineCache *pSrcCaches) const {
7470 bool skip = false;
7471 if (pSrcCaches) {
7472 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7473 if (pSrcCaches[index0] == dstCache) {
7474 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7475 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7476 report_data->FormatHandle(dstCache).c_str());
7477 break;
7478 }
7479 }
7480 }
7481 return skip;
7482}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007483
7484bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
7485 VkImageLayout imageLayout, const VkClearColorValue *pColor,
7486 uint32_t rangeCount,
7487 const VkImageSubresourceRange *pRanges) const {
7488 bool skip = false;
7489 if (!pColor) {
7490 skip |=
7491 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
7492 }
7493 return skip;
7494}
7495
7496bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
7497 const VkRenderPassBeginInfo *const rp_begin) const {
7498 bool skip = false;
7499 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
7500 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
7501 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02007502 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007503 func_name, rp_begin->clearValueCount);
7504 }
7505 return skip;
7506}
7507
7508bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7509 VkSubpassContents) const {
7510 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
7511 return skip;
7512}
7513
7514bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
7515 const VkRenderPassBeginInfo *pRenderPassBegin,
7516 const VkSubpassBeginInfo *) const {
7517 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
7518 return skip;
7519}
7520
7521bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7522 const VkSubpassBeginInfo *) const {
7523 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
7524 return skip;
7525}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02007526
7527bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
7528 uint32_t firstDiscardRectangle,
7529 uint32_t discardRectangleCount,
7530 const VkRect2D *pDiscardRectangles) const {
7531 bool skip = false;
7532
7533 if (pDiscardRectangles) {
7534 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
7535 const int64_t x_sum =
7536 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
7537 if (x_sum > std::numeric_limits<int32_t>::max()) {
7538 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
7539 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7540 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7541 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
7542 }
7543
7544 const int64_t y_sum =
7545 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
7546 if (y_sum > std::numeric_limits<int32_t>::max()) {
7547 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
7548 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7549 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7550 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
7551 }
7552 }
7553 }
7554
7555 return skip;
7556}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02007557
7558bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
7559 uint32_t queryCount, size_t dataSize, void *pData,
7560 VkDeviceSize stride, VkQueryResultFlags flags) const {
7561 bool skip = false;
7562
7563 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
7564 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
7565 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
7566 }
7567
7568 return skip;
7569}