blob: 46471b84a2106a76085d1f66ca1d7f86f0054193 [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 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
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070039bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050040 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060041 bool skip = false;
42
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070043 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060044
45 if (result == VK_STRING_ERROR_NONE) {
46 return skip;
47 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070049 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070051 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
52 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060053 }
54 return skip;
55}
56
Jeff Bolz46c0ea02019-10-09 13:06:29 -050057bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060058 bool skip = false;
59 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
60 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080061 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
62 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070063 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
64 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
65 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060066 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070067 skip |= LogWarning(instance, kVUIDUndefined,
68 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
69 "Assuming 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 }
72 }
73 return skip;
74}
75
Jeff Bolz46c0ea02019-10-09 13:06:29 -050076bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060077 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060078 // Create and use a local instance extension object, as an actual instance has not been created yet
79 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
80 InstanceExtensions local_instance_extensions;
81 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
82
John Zulauf620755c2018-04-16 11:00:43 -060083 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060084 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
85 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060086 }
87
88 return skip;
89}
90
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060091bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
92 if (instance_extensions.vk_khr_get_physical_device_properties_2) {
93 // Struct is legal IF it's supported
94 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
95 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
96 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
97 if (enum_iter != dev_exts_enumerated->second.cend()) {
98 return true;
99 }
100 }
101 return false;
102}
103
Tony-LunarG866843d2020-05-13 11:22:42 -0600104bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
105 const VkValidationFeaturesEXT *validation_features) const {
106 bool skip = false;
107 bool debug_printf = false;
108 bool gpu_assisted = false;
109 bool reserve_slot = false;
110 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
111 switch (validation_features->pEnabledValidationFeatures[i]) {
112 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
113 gpu_assisted = true;
114 break;
115
116 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
117 debug_printf = true;
118 break;
119
120 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
121 reserve_slot = true;
122 break;
123
124 default:
125 break;
126 }
127 }
128 if (reserve_slot && !gpu_assisted) {
129 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
130 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
131 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
132 }
133 if (gpu_assisted && debug_printf) {
134 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
135 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
136 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
137 }
138
139 return skip;
140}
141
John Zulauf620755c2018-04-16 11:00:43 -0600142template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700143ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
144 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600145 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700146 ExtEnabled state =
147 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600148 return state;
149}
150
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700151bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500152 const VkAllocationCallbacks *pAllocator,
153 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700154 bool skip = false;
155 // Note: From the spec--
156 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
157 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
158 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700159 ? pCreateInfo->pApplicationInfo->apiVersion
160 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700161 skip |= validate_api_version(local_api_version, api_version);
162 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600163 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
164 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
165
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700166 return skip;
167}
168
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700169void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700170 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
171 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700172 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
173 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700174 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700175 this->instance_extensions = instance_data->instance_extensions;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600176
177 uint32_t pdev_count = 0;
178 DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, nullptr);
179 std::vector<VkPhysicalDevice> physical_devices;
180 physical_devices.resize(pdev_count);
181 DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, physical_devices.data());
182
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600183 for (uint32_t i = 0; i < physical_devices.size(); i++) {
184 auto phys_dev_props = new VkPhysicalDeviceProperties;
185 DispatchGetPhysicalDeviceProperties(physical_devices[i], phys_dev_props);
186 physical_device_properties_map[physical_devices[i]] = phys_dev_props;
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600187
188 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
189 uint32_t ext_count = 0;
190 std::unordered_set<std::string> dev_exts_enumerated{};
191 std::vector<VkExtensionProperties> ext_props{};
192 instance_dispatch_table.EnumerateDeviceExtensionProperties(physical_devices[i], nullptr, &ext_count, nullptr);
193 ext_props.resize(ext_count);
194 instance_dispatch_table.EnumerateDeviceExtensionProperties(physical_devices[i], nullptr, &ext_count, ext_props.data());
195 for (uint32_t j = 0; j < ext_count; j++) {
196 dev_exts_enumerated.insert(ext_props[j].extensionName);
197 }
198 device_extensions_enumerated[physical_devices[i]] = std::move(dev_exts_enumerated);
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600199 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700200}
201
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600202void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
203 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
204 delete (it->second);
205 it = physical_device_properties_map.erase(it);
206 }
207};
208
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700209void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700210 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700211 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700212 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700213 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
214 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700215
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700216 // Parmeter validation also uses extension data
217 stateless_validation->device_extensions = this->device_extensions;
218
219 VkPhysicalDeviceProperties device_properties = {};
220 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600221 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700222 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
223
224 if (device_extensions.vk_nv_shading_rate_image) {
225 // Get the needed shading rate image limits
226 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
227 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600228 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700229 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
230 }
231
232 if (device_extensions.vk_nv_mesh_shader) {
233 // Get the needed mesh shader limits
234 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
235 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600236 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700237 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
238 }
239
Jason Macnak5c954952019-07-09 15:46:12 -0700240 if (device_extensions.vk_nv_ray_tracing) {
241 // Get the needed ray tracing limits
242 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
243 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
244 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500245 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
246 }
247
sourav parmarcd5fb182020-07-17 12:58:44 -0700248 if (device_extensions.vk_khr_ray_tracing_pipeline) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500249 // Get the needed ray tracing limits
sourav parmarcd5fb182020-07-17 12:58:44 -0700250 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500251 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
252 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
253 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700254 }
255
sourav parmarcd5fb182020-07-17 12:58:44 -0700256 if (device_extensions.vk_khr_acceleration_structure) {
257 // Get the needed ray tracing acc structure limits
258 auto acc_structure_props = lvl_init_struct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
259 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&acc_structure_props);
260 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
261 phys_dev_ext_props.acc_structure_props = acc_structure_props;
262 }
263
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700264 if (device_extensions.vk_ext_transform_feedback) {
265 // Get the needed transform feedback limits
266 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
267 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
268 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
269 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
270 }
271
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800272 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
273
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700274 // Save app-enabled features in this device's validation object
275 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200276 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
277 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
278 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
279 if (features2) {
280 tmp_features2_state.features = features2->features;
281 } else if (pCreateInfo->pEnabledFeatures) {
282 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700283 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200284 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700285 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200286 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700287 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200288 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700289}
290
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700291bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500292 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600293 bool skip = false;
294
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200295 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
296 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
297 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600298 }
299
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700300 // If this device supports VK_KHR_portability_subset, it must be enabled
301 const std::string portability_extension_name("VK_KHR_portability_subset");
302 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
303 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
304 bool portability_requested = false;
305
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200306 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
307 skip |=
308 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
309 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
310 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
311 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700312 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
313 portability_requested = true;
314 }
315 }
316
317 if (portability_supported && !portability_requested) {
318 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
319 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
320 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600321 }
322
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200323 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700324 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
325 bool negative_viewport =
326 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200327 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700328 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
329 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
330 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200331 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600332 }
333
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600334 {
335 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
336 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
337 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700338 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
339 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
340 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600341 }
342 }
343
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600344 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
345 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600346 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
347 if (features2) {
348 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700349 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700350 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
351 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600352 }
353 }
354
Locke77fad1c2019-04-16 13:09:03 -0600355 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500356 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
357 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
358 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
359 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
360 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
361 }
sourav parmarcd5fb182020-07-17 12:58:44 -0700362 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
363 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
364 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
365 skip |= LogError(
366 device,
367 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
368 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
369 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700370 }
Locke77fad1c2019-04-16 13:09:03 -0600371 auto vertex_attribute_divisor_features =
372 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600373 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
374 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
375 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
376 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600377 }
378
Tony-LunarG28017bc2020-01-23 14:40:25 -0700379 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
380 if (vulkan_11_features) {
381 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
382 while (current) {
383 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
384 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
385 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
386 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
387 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
388 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700389 skip |= LogError(
390 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700391 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
392 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
393 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
394 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
395 break;
396 }
397 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
398 }
399 }
400
401 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
402 if (vulkan_12_features) {
403 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
404 while (current) {
405 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
406 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
407 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
408 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
409 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
410 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
411 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
412 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
413 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
414 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
415 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
416 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
417 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700418 skip |= LogError(
419 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700420 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
421 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
422 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
423 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
424 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
425 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
426 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
427 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
428 break;
429 }
430 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
431 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700432 // Check features are enabled if matching extension is passed in as well
433 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
434 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
435 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
436 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
437 skip |= LogError(
438 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
439 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
440 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
441 }
442 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
443 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
444 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
445 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
446 "is not VK_TRUE.",
447 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
448 }
449 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
450 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
451 skip |= LogError(
452 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
453 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
454 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
455 }
456 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
457 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
458 skip |= LogError(
459 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
460 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
461 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
462 }
463 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
464 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
465 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
466 skip |=
467 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
468 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
469 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
470 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
471 }
472 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700473 }
474
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600475 // Validate pCreateInfo->pQueueCreateInfos
476 if (pCreateInfo->pQueueCreateInfos) {
477 std::unordered_set<uint32_t> set;
478
479 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700480 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
481 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600482 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700483 skip |=
484 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
485 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
486 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
487 "index value.",
488 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600489 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700490 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
491 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
492 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
493 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600494 } else {
495 set.insert(requested_queue_family);
496 }
497
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700498 if (queue_create_info.pQueuePriorities != nullptr) {
499 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
500 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600501 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700502 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
503 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
504 "] (=%f) is not between 0 and 1 (inclusive).",
505 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600506 }
507 }
508 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700509
510 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700511 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700512 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
513 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
514 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700515 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700516 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700517 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700518 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700519 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700520 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
521 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
522 "protectedMemory feature being set as well.");
523 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600524 }
525 }
526
sfricke-samsung30a57412020-05-15 21:14:54 -0700527 // feature dependencies for VK_KHR_variable_pointers
528 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700529 VkBool32 variable_pointers = VK_FALSE;
530 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700531 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700532 variable_pointers = vulkan_11_features->variablePointers;
533 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700534 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700535 variable_pointers = variable_pointers_features->variablePointers;
536 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700537 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700538 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700539 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
540 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
541 }
542
sfricke-samsungfd76c342020-05-29 23:13:43 -0700543 // feature dependencies for VK_KHR_multiview
544 const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
545 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700546 VkBool32 multiview_geometry_shader = VK_FALSE;
547 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700548 if (vulkan_11_features) {
549 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700550 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
551 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700552 } else if (multiview_features) {
553 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700554 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
555 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700556 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700557 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700558 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
559 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
560 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700561 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700562 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
563 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
564 }
565
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600566 return skip;
567}
568
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500569bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700570 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700571 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
572 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
573 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600574 }
575
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700576 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600577}
578
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700579bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500580 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100581 bool skip = false;
582
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600583 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700584 skip |=
585 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600586
587 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
588 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
589 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
590 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700591 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
592 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
593 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600594 }
595
596 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
597 // queueFamilyIndexCount uint32_t values
598 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700599 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
600 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
601 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
602 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600603 }
604 }
605
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700606 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
607 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
608 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
609 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
610 }
611
612 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
613 skip |=
614 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
615 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
616 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
617 }
618
619 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
620 skip |=
621 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
622 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
623 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
624 }
625
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
627 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
628 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
629 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700630 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
631 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
632 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600633 }
634 }
635
636 return skip;
637}
638
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700639bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500640 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600641 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600642
643 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600644 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
645 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
646 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
647 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700648 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
649 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
650 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600651 }
652
653 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
654 // queueFamilyIndexCount uint32_t values
655 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700656 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
657 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
658 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
659 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600660 }
661 }
662
Dave Houlton413a6782018-05-22 13:01:54 -0600663 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700664 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600665 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700666 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600667 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700668 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600669
Dave Houlton413a6782018-05-22 13:01:54 -0600670 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700671 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600672 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700673 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600674
Dave Houlton130c0212018-01-29 13:39:56 -0700675 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700676 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
677 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700678 skip |= LogError(
679 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600680 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
681 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700682 }
683
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600684 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100685 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
686 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700687 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
688 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
689 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600690 }
691
692 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100693 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
694 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700695 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
696 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
697 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
698 ") are not equal.",
699 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100700 }
701
702 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700703 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
704 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
705 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
706 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100707 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600708 }
709
710 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 skip |= LogError(
712 device, "VUID-VkImageCreateInfo-imageType-00957",
713 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714 }
715 }
716
Dave Houlton130c0212018-01-29 13:39:56 -0700717 // 3D image may have only 1 layer
718 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700719 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
720 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700721 }
722
Dave Houlton130c0212018-01-29 13:39:56 -0700723 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
724 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
725 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
726 // At least one of the legal attachment bits must be set
727 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
729 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700730 }
731 // No flags other than the legal attachment bits may be set
732 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
733 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700734 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
735 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700736 }
737 }
738
Jeff Bolzef40fec2018-09-01 22:04:34 -0500739 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700740 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500741 // Max mip levels is different for corner-sampled images vs normal images.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700742 uint32_t max_mip_levels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
743 ? static_cast<uint32_t>(ceil(log2(max_dim)))
744 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
745 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600746 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700747 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
748 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
749 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600750 }
751
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600752 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700753 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
754 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
755 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600756 }
757
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700758 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700759 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
760 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
761 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100762 }
763
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700764 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
765 skip |= LogError(
766 device, "VUID-VkImageCreateInfo-flags-01924",
767 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
768 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
769 }
770
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600771 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
772 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
773 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
774 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700775 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
776 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
777 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600778 }
779
780 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
781 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
782 // Linear tiling is unsupported
783 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700784 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700785 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
786 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600787 }
788
789 // Sparse 1D image isn't valid
790 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700791 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
792 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600793 }
794
795 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700796 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
798 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
799 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600800 }
801
802 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700803 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700804 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
805 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
806 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600807 }
808
809 // Multi-sample 2D image when device doesn't support it
810 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700811 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600812 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700813 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
814 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
815 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700816 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600817 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700818 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
819 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
820 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700821 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600822 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700823 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
824 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
825 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700826 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600827 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700828 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
829 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
830 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600831 }
832 }
833 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500834
Jeff Bolz9af91c52018-09-01 21:53:57 -0500835 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
836 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700837 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
838 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
839 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500840 }
841 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700842 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
843 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
844 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500845 }
846 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700847 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
848 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
849 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500850 }
851 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500852
853 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600854 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700855 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
856 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
857 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500858 }
859
Dave Houlton142c4cb2018-10-17 15:04:41 -0600860 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700861 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
862 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
863 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
864 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500865 }
866
Dave Houlton142c4cb2018-10-17 15:04:41 -0600867 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
869 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
870 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
871 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500872 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600873 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700874 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
875 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
876 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
877 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500878 }
879 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500880
sfricke-samsung8f658d42020-05-03 20:12:24 -0700881 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
882 (FormatHasDepth(pCreateInfo->format) == false)) {
883 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
884 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
885 "format must be a depth or depth/stencil format.");
886 }
887
Andrew Fobel3abeb992020-01-20 16:33:22 -0500888 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
889 if (image_stencil_struct != nullptr) {
890 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
891 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
892 // No flags other than the legal attachment bits may be set
893 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
894 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700895 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
896 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
897 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
898 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500899 }
900 }
901
902 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
903 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
904 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
905 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700906 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
907 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
908 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
909 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500910 }
911
912 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
913 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700914 LogError(device, "VUID-VkImageCreateInfo-format-02537",
915 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
916 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
917 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500918 }
919 }
920
921 if (!physical_device_features.shaderStorageImageMultisample &&
922 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
923 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
924 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700925 LogError(device, "VUID-VkImageCreateInfo-format-02538",
926 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
927 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
928 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500929 }
930
931 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
932 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700933 skip |= LogError(
934 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500935 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
936 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
937 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
938 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
939 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700940 skip |= LogError(
941 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500942 "vkCreateImage(): Depth-stencil image in which usage does not include "
943 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
944 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
945 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
946 }
947
948 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
949 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700950 skip |= LogError(
951 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500952 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
953 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
954 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
955 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
956 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700957 skip |= LogError(
958 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500959 "vkCreateImage(): Depth-stencil image in which usage does not include "
960 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
961 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
962 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
963 }
964 }
965 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700966
967 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
968 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
969 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
970 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
971 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
972 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700973
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -0700974 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700975 if (device_extensions.vk_ext_image_drm_format_modifier) {
976 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
977 const auto drm_format_mod_explict =
978 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
979 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
980 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
981 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
982 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
983 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
984 "either VkImageDrmFormatModifierListCreateInfoEXT or "
985 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -0700986 } else if (drm_format_mod_list != nullptr) {
987 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
988 } else if (drm_format_mod_list != nullptr) {
989 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
990 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
991 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700992 }
993 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
994 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
995 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
996 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
997 "in the pNext chain");
998 }
999 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001000
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001001 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001002 bool image_create_maybe_linear = false;
1003 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1004 image_create_maybe_linear = true;
1005 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1006 image_create_maybe_linear = false;
1007 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1008 image_create_maybe_linear =
1009 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001010 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001011 }
1012
1013 // If multi-sample, validate type, usage, tiling and mip levels.
1014 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
1015 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
1016 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1017 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1018 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1019 }
1020
1021 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
1022 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1023 image_create_maybe_linear)) {
1024 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1025 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1026 }
1027
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001028 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1029 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1030 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1031 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1032 "imageType must be VK_IMAGE_TYPE_2D.");
1033 }
1034 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1035 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1036 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1037 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1038 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001039 }
1040 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
1041 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1042 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1043 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1044 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1045 }
1046 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1047 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1048 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1049 "imageType must be VK_IMAGE_TYPE_2D.");
1050 }
1051 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
1052 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1053 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1054 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1055 }
1056 if (pCreateInfo->mipLevels != 1) {
1057 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1058 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1059 pCreateInfo->mipLevels);
1060 }
1061 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001062
1063 const auto swapchain_create_info = lvl_find_in_chain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
1064 if (swapchain_create_info != nullptr) {
1065 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1066 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1067 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1068 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1069 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1070 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1071
1072 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1073 // also implicitly forces the check above that extent.depth is 1
1074 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1075 string_VkImageType(pCreateInfo->imageType));
1076 }
1077 if (pCreateInfo->mipLevels != 1) {
1078 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1079 pCreateInfo->mipLevels);
1080 }
1081 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1082 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1083 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1084 }
1085 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1086 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1087 base_message, string_VkImageTiling(pCreateInfo->tiling));
1088 }
1089 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1090 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1091 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1092 }
1093 const VkImageCreateFlags valid_flags =
1094 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
1095 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR);
1096 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1097 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1098 pCreateInfo->flags);
1099 }
1100 }
1101 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001102 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001103
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001104 return skip;
1105}
1106
Jeff Bolz99e3f632020-03-24 22:59:22 -05001107bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1108 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1109 bool skip = false;
1110
1111 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001112 // Validate feature set if using CUBE_ARRAY
1113 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1114 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1115 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1116 "enabling the imageCubeArray feature.");
1117 }
1118
Jeff Bolz99e3f632020-03-24 22:59:22 -05001119 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1120 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1121 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001122 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001123 pCreateInfo->subresourceRange.layerCount);
1124 }
1125 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001126 skip |= LogError(
1127 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1128 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1129 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001130 }
1131 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001132
1133 auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
1134 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1135 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1136 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1137 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1138 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1139 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1140 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1141 }
1142 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1143 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1144 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1145 "not an ASTC format.",
1146 string_VkFormat(pCreateInfo->format));
1147 }
1148 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001149
1150 auto ycbcr_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
1151 if (ycbcr_conversion != nullptr) {
1152 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1153 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1154 skip |= LogError(
1155 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1156 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1157 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1158 "r swizzle = %s\n"
1159 "g swizzle = %s\n"
1160 "b swizzle = %s\n"
1161 "a swizzle = %s\n",
1162 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1163 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1164 }
1165 }
1166 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001167 }
1168 return skip;
1169}
1170
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001171bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001172 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001173 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001174
1175 // Note: for numerical correctness
1176 // - float comparisons should expect NaN (comparison always false).
1177 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1178
1179 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001180 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001181 if (v1_f <= 0.0f) return true;
1182
1183 float intpart;
1184 const float fract = modff(v1_f, &intpart);
1185
1186 assert(std::numeric_limits<float>::radix == 2);
1187 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1188 if (intpart >= u32_max_plus1) return false;
1189
1190 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001191 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001192 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001193 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001194 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001195 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001196 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001197 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001198 };
1199
1200 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1201 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1202 return (v1_f <= v2_f);
1203 };
1204
1205 // width
1206 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001207 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001208
1209 if (!(viewport.width > 0.0f)) {
1210 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001211 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1212 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001213 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1214 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001215 skip |= LogError(object, "VUID-VkViewport-width-01771",
1216 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1217 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001218 }
1219
1220 // height
1221 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001222 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001223 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001224
1225 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1226 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001227 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1228 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001229 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1230 height_healthy = false;
1231
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001232 skip |= LogError(object, "VUID-VkViewport-height-01773",
1233 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1234 ").",
1235 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001236 }
1237
1238 // x
1239 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001240 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001241 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001242 skip |= LogError(object, "VUID-VkViewport-x-01774",
1243 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1244 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001245 }
1246
1247 // x + width
1248 if (x_healthy && width_healthy) {
1249 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001250 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001251 skip |= LogError(
1252 object, "VUID-VkViewport-x-01232",
1253 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1254 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1255 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001256 }
1257 }
1258
1259 // y
1260 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001261 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001262 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001263 skip |= LogError(object, "VUID-VkViewport-y-01775",
1264 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1265 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001266 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001267 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001268 skip |= LogError(object, "VUID-VkViewport-y-01776",
1269 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1270 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001271 }
1272
1273 // y + height
1274 if (y_healthy && height_healthy) {
1275 const float boundary = viewport.y + viewport.height;
1276
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001277 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001278 skip |= LogError(object, "VUID-VkViewport-y-01233",
1279 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1280 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1281 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001282 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001283 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001284 LogError(object, "VUID-VkViewport-y-01777",
1285 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1286 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1287 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001288 }
1289 }
1290
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001291 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001292 // minDepth
1293 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001294 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001295
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001296 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1297 "[0.0, 1.0] range.",
1298 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001299 }
1300
1301 // maxDepth
1302 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001303 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001304
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001305 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1306 "[0.0, 1.0] range.",
1307 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001308 }
1309 }
1310
1311 return skip;
1312}
1313
Dave Houlton142c4cb2018-10-17 15:04:41 -06001314struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001315 VkShadingRatePaletteEntryNV shadingRate;
1316 uint32_t width;
1317 uint32_t height;
1318};
1319
1320// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001321static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001322 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1323 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1324 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1325 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1326 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1327 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001328};
1329
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001330bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001331 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001332
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001333 SampleOrderInfo *sample_order_info;
1334 uint32_t info_idx = 0;
1335 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1336 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1337 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001338 break;
1339 }
1340 }
1341
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001342 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001343 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1344 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1345 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001346 return skip;
1347 }
1348
Dave Houlton142c4cb2018-10-17 15:04:41 -06001349 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001350 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001351 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1352 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1353 ") must "
1354 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1355 "is set in framebufferNoAttachmentsSampleCounts.",
1356 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001357 }
1358
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001359 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001360 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1361 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1362 ") must "
1363 "be equal to the product of sampleCount (=%" PRIu32
1364 "), the fragment width for shadingRate "
1365 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001366 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001367 }
1368
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001369 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001370 skip |= LogError(
1371 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001372 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1373 ") must "
1374 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001375 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001376 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001377
1378 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001379 // the first width*height*sampleCount bits to all be set. Note: There is no
1380 // guarantee that 64 bits is enough, but practically it's unlikely for an
1381 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001382 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001383 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001384 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001385 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1386 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001387 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1388 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001389 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001390 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001391 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1392 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001393 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001394 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001395 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1396 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001397 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001398 uint32_t idx =
1399 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1400 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001401 }
1402
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001403 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1404 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001405 skip |= LogError(
1406 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001407 "The array pSampleLocations must contain exactly one entry for "
1408 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001409 }
1410
1411 return skip;
1412}
1413
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001414bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1415 uint32_t createInfoCount,
1416 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1417 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001418 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001419 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001420
1421 if (pCreateInfos != nullptr) {
1422 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001423 bool has_dynamic_viewport = false;
1424 bool has_dynamic_scissor = false;
1425 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001426 bool has_dynamic_depth_bias = false;
1427 bool has_dynamic_blend_constant = false;
1428 bool has_dynamic_depth_bounds = false;
1429 bool has_dynamic_stencil_compare = false;
1430 bool has_dynamic_stencil_write = false;
1431 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001432 bool has_dynamic_viewport_w_scaling_nv = false;
1433 bool has_dynamic_discard_rectangle_ext = false;
1434 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001435 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001436 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001437 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001438 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001439 bool has_dynamic_cull_mode = false;
1440 bool has_dynamic_front_face = false;
1441 bool has_dynamic_primitive_topology = false;
1442 bool has_dynamic_viewport_with_count = false;
1443 bool has_dynamic_scissor_with_count = false;
1444 bool has_dynamic_vertex_input_binding_stride = false;
1445 bool has_dynamic_depth_test_enable = false;
1446 bool has_dynamic_depth_write_enable = false;
1447 bool has_dynamic_depth_compare_op = false;
1448 bool has_dynamic_depth_bounds_test_enable = false;
1449 bool has_dynamic_stencil_test_enable = false;
1450 bool has_dynamic_stencil_op = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07001451 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
1452 skip |=
1453 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
1454 "vkCreateGraphicsPipelines: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
1455 }
Petr Kraus299ba622017-11-24 03:09:03 +01001456 if (pCreateInfos[i].pDynamicState != nullptr) {
1457 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1458 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1459 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001460 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1461 if (has_dynamic_viewport == true) {
1462 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1463 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1464 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1465 i);
1466 }
1467 has_dynamic_viewport = true;
1468 }
1469 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1470 if (has_dynamic_scissor == true) {
1471 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1472 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1473 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1474 i);
1475 }
1476 has_dynamic_scissor = true;
1477 }
1478 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1479 if (has_dynamic_line_width == true) {
1480 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1481 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1482 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1483 i);
1484 }
1485 has_dynamic_line_width = true;
1486 }
1487 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1488 if (has_dynamic_depth_bias == true) {
1489 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1490 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1491 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1492 i);
1493 }
1494 has_dynamic_depth_bias = true;
1495 }
1496 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1497 if (has_dynamic_blend_constant == true) {
1498 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1499 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1500 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1501 i);
1502 }
1503 has_dynamic_blend_constant = true;
1504 }
1505 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1506 if (has_dynamic_depth_bounds == true) {
1507 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1508 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1509 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1510 i);
1511 }
1512 has_dynamic_depth_bounds = true;
1513 }
1514 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1515 if (has_dynamic_stencil_compare == true) {
1516 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1517 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1518 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1519 i);
1520 }
1521 has_dynamic_stencil_compare = true;
1522 }
1523 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1524 if (has_dynamic_stencil_write == true) {
1525 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1526 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1527 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1528 i);
1529 }
1530 has_dynamic_stencil_write = true;
1531 }
1532 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1533 if (has_dynamic_stencil_reference == true) {
1534 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1535 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1536 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1537 i);
1538 }
1539 has_dynamic_stencil_reference = true;
1540 }
1541 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1542 if (has_dynamic_viewport_w_scaling_nv == true) {
1543 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1544 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1545 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1546 i);
1547 }
1548 has_dynamic_viewport_w_scaling_nv = true;
1549 }
1550 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1551 if (has_dynamic_discard_rectangle_ext == true) {
1552 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1553 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1554 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1555 i);
1556 }
1557 has_dynamic_discard_rectangle_ext = true;
1558 }
1559 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1560 if (has_dynamic_sample_locations_ext == true) {
1561 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1562 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1563 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1564 i);
1565 }
1566 has_dynamic_sample_locations_ext = true;
1567 }
1568 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1569 if (has_dynamic_exclusive_scissor_nv == true) {
1570 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1571 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1572 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1573 i);
1574 }
1575 has_dynamic_exclusive_scissor_nv = true;
1576 }
1577 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1578 if (has_dynamic_shading_rate_palette_nv == true) {
1579 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1580 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1581 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1582 i);
1583 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001584 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001585 }
1586 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1587 if (has_dynamic_viewport_course_sample_order_nv == true) {
1588 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1589 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1590 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1591 i);
1592 }
1593 has_dynamic_viewport_course_sample_order_nv = true;
1594 }
1595 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1596 if (has_dynamic_line_stipple == true) {
1597 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1598 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1599 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1600 i);
1601 }
1602 has_dynamic_line_stipple = true;
1603 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001604 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1605 if (has_dynamic_cull_mode) {
1606 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1607 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1608 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1609 i);
1610 }
1611 has_dynamic_cull_mode = true;
1612 }
1613 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1614 if (has_dynamic_front_face) {
1615 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1616 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1617 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1618 i);
1619 }
1620 has_dynamic_front_face = true;
1621 }
1622 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1623 if (has_dynamic_primitive_topology) {
1624 skip |= LogError(
1625 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1626 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1627 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1628 i);
1629 }
1630 has_dynamic_primitive_topology = true;
1631 }
1632 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1633 if (has_dynamic_viewport_with_count) {
1634 skip |= LogError(
1635 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1636 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1637 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1638 i);
1639 }
1640 has_dynamic_viewport_with_count = true;
1641 }
1642 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1643 if (has_dynamic_scissor_with_count) {
1644 skip |= LogError(
1645 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1646 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1647 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1648 i);
1649 }
1650 has_dynamic_scissor_with_count = true;
1651 }
1652 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1653 if (has_dynamic_vertex_input_binding_stride) {
1654 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1655 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1656 "listed twice in the "
1657 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1658 i);
1659 }
1660 has_dynamic_vertex_input_binding_stride = true;
1661 }
1662 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1663 if (has_dynamic_depth_test_enable) {
1664 skip |= LogError(
1665 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1666 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1667 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1668 i);
1669 }
1670 has_dynamic_depth_test_enable = true;
1671 }
1672 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1673 if (has_dynamic_depth_write_enable) {
1674 skip |= LogError(
1675 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1676 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1677 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1678 i);
1679 }
1680 has_dynamic_depth_write_enable = true;
1681 }
1682 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1683 if (has_dynamic_depth_compare_op) {
1684 skip |=
1685 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1686 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1687 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1688 i);
1689 }
1690 has_dynamic_depth_compare_op = true;
1691 }
1692 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1693 if (has_dynamic_depth_bounds_test_enable) {
1694 skip |= LogError(
1695 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1696 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1697 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1698 i);
1699 }
1700 has_dynamic_depth_bounds_test_enable = true;
1701 }
1702 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1703 if (has_dynamic_stencil_test_enable) {
1704 skip |= LogError(
1705 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1706 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1707 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1708 i);
1709 }
1710 has_dynamic_stencil_test_enable = true;
1711 }
1712 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1713 if (has_dynamic_stencil_op) {
1714 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1715 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1716 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1717 i);
1718 }
1719 has_dynamic_stencil_op = true;
1720 }
Petr Kraus299ba622017-11-24 03:09:03 +01001721 }
1722 }
1723
Peter Chen85366392019-05-14 15:20:11 -04001724 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1725 if ((feedback_struct != nullptr) &&
1726 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001727 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1728 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1729 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1730 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1731 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001732 }
1733
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001734 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001735
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001736 // Collect active stages and other information
1737 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001738 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001739 bool has_eval = false;
1740 bool has_control = false;
1741 if (pCreateInfos[i].pStages != nullptr) {
1742 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1743 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1744
1745 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1746 has_control = true;
1747 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1748 has_eval = true;
1749 }
1750
1751 skip |= validate_string(
1752 "vkCreateGraphicsPipelines",
1753 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1754 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1755 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001756 }
1757
1758 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1759 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1760 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1761 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1762 pCreateInfos[i].pTessellationState,
1763 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1764 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1765
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001766 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001767 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1768
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001769 skip |= validate_struct_pnext(
1770 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1771 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
1772 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
1773 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
1774 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1775 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001776
1777 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1778 pCreateInfos[i].pTessellationState->flags,
1779 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1780 }
1781
1782 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1783 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1784 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1785 pCreateInfos[i].pInputAssemblyState,
1786 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1787 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1788
1789 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1790 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001791 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001792
1793 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1794 pCreateInfos[i].pInputAssemblyState->flags,
1795 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1796
1797 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1798 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1799 pCreateInfos[i].pInputAssemblyState->topology,
1800 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1801
1802 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1803 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1804 }
1805
1806 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001807 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001808
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001809 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001810 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1811 "vkCreateGraphicsPipelines: pararameter "
1812 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1813 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001814 }
1815
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001816 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001817 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1818 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1819 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1820 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001821 allowed_structs_vk_pipeline_vertex_input_state_create_info,
1822 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08001823 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001824 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1825 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001826 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001827 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1828 skip |=
1829 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1830 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1831 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1832 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1833 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1834
1835 skip |= validate_array(
1836 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1837 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1838 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1839 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1840
1841 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001842 for (uint32_t vertex_binding_description_index = 0;
1843 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1844 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001845 skip |= validate_ranged_enum(
1846 "vkCreateGraphicsPipelines",
1847 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1848 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001849 pCreateInfos[i]
1850 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
1851 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001852 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1853 }
1854 }
1855
1856 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001857 for (uint32_t vertex_attribute_description_index = 0;
1858 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1859 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001860 skip |= validate_ranged_enum(
1861 "vkCreateGraphicsPipelines",
1862 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1863 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001864 pCreateInfos[i]
1865 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
1866 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001867 "VUID-VkVertexInputAttributeDescription-format-parameter");
1868 }
1869 }
1870
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001871 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001872 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1873 "vkCreateGraphicsPipelines: pararameter "
1874 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1875 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1876 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001877 }
1878
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001879 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001880 skip |=
1881 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1882 "vkCreateGraphicsPipelines: pararameter "
1883 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1884 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1885 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001886 }
1887
1888 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001889 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1890 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001891 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1892 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001893 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1894 "vkCreateGraphicsPipelines: parameter "
1895 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1896 "(%" PRIu32 ") is not distinct.",
1897 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001898 }
1899 vertex_bindings.insert(vertex_bind_desc.binding);
1900
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001901 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001902 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1903 "vkCreateGraphicsPipelines: parameter "
1904 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1905 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1906 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001907 }
1908
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001909 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001910 skip |=
1911 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1912 "vkCreateGraphicsPipelines: parameter "
1913 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1914 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1915 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001916 }
1917 }
1918
Peter Kohautc7d9d392018-07-15 00:34:07 +02001919 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001920 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1921 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001922 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1923 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001924 skip |= LogError(
1925 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001926 "vkCreateGraphicsPipelines: parameter "
1927 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1928 i, d, vertex_attrib_desc.location);
1929 }
1930 attribute_locations.insert(vertex_attrib_desc.location);
1931
1932 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1933 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001934 skip |= LogError(
1935 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001936 "vkCreateGraphicsPipelines: parameter "
1937 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1938 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1939 i, d, vertex_attrib_desc.binding, i);
1940 }
1941
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001942 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001943 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1944 "vkCreateGraphicsPipelines: parameter "
1945 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1946 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1947 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001948 }
1949
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001950 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001951 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1952 "vkCreateGraphicsPipelines: parameter "
1953 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1954 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1955 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001956 }
1957
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001958 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001959 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1960 "vkCreateGraphicsPipelines: parameter "
1961 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1962 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1963 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001964 }
1965 }
1966 }
1967
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001968 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1969 if (has_control && has_eval) {
1970 if (pCreateInfos[i].pTessellationState == nullptr) {
1971 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1972 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1973 "shader stage and a tessellation evaluation shader stage, "
1974 "pCreateInfos[%d].pTessellationState must not be NULL.",
1975 i, i);
1976 } else {
1977 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1978 skip |= validate_struct_pnext(
1979 "vkCreateGraphicsPipelines",
1980 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1981 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1982 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1983 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001984
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001985 skip |= validate_reserved_flags(
1986 "vkCreateGraphicsPipelines",
1987 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1988 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001989
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001990 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1991 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1992 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1993 "vkCreateGraphicsPipelines: invalid parameter "
1994 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1995 "should be >0 and <=%u.",
1996 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1997 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001998 }
1999 }
2000 }
2001
2002 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2003 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2004 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2005 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002006 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2007 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2008 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2009 "].pViewportState (=NULL) is not a valid pointer.",
2010 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002011 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002012 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2013
2014 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002015 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2016 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2017 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2018 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002019 }
2020
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002021 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002022 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002023 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2024 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002025 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2026 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002027 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002028 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002029 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002030 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002031 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002032 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2033 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002034 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2035 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2036 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002037 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002038
2039 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002040 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002041 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002042 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002043
Dave Houlton142c4cb2018-10-17 15:04:41 -06002044 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
2045 pCreateInfos[i].pViewportState->pNext);
2046 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
2047 pCreateInfos[i].pViewportState->pNext);
2048 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
2049 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002050 const auto vp_swizzle_struct =
2051 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002052 const auto vp_w_scaling_struct =
2053 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002054
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002055 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002056 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002057 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2058 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2059 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2060 ") is not 1.",
2061 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002062 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002063
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002064 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002065 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2066 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2067 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2068 ") is not 1.",
2069 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002070 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002071
Dave Houlton142c4cb2018-10-17 15:04:41 -06002072 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2073 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002074 skip |= LogError(
2075 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2076 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2077 "disabled, but pCreateInfos[%" PRIu32
2078 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2079 ") is not 1.",
2080 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002081 }
2082
Jeff Bolz9af91c52018-09-01 21:53:57 -05002083 if (shading_rate_image_struct &&
2084 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002085 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2086 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2087 "disabled, but pCreateInfos[%" PRIu32
2088 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2089 ") is neither 0 nor 1.",
2090 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002091 }
2092
Petr Krausa6103552017-11-16 21:21:58 +01002093 } else { // multiViewport enabled
2094 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002095 if (!has_dynamic_viewport_with_count) {
2096 skip |= LogError(
2097 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2098 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2099 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002100 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002101 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2102 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2103 "].pViewportState->viewportCount (=%" PRIu32
2104 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2105 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002106 } else if (has_dynamic_viewport_with_count) {
2107 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2108 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2109 "].pViewportState->viewportCount (=%" PRIu32
2110 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2111 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002112 }
Petr Krausa6103552017-11-16 21:21:58 +01002113
2114 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002115 if (!has_dynamic_scissor_with_count) {
2116 skip |= LogError(
2117 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2118 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2119 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002120 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002121 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2122 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2123 "].pViewportState->scissorCount (=%" PRIu32
2124 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2125 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002126 } else if (has_dynamic_scissor_with_count) {
2127 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2128 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2129 "].pViewportState->scissorCount (=%" PRIu32
2130 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2131 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002132 }
2133 }
2134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002135 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002136 skip |=
2137 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2138 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2139 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2140 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002141 }
2142
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002143 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002144 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2145 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2146 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2147 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2148 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002149 }
2150
Piers Daniell39842ee2020-07-10 16:42:33 -06002151 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2152 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002153 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2154 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2155 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2156 "].pViewportState->viewportCount (=%" PRIu32 ").",
2157 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002158 }
2159
Dave Houlton142c4cb2018-10-17 15:04:41 -06002160 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002161 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002162 skip |=
2163 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2164 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2165 ") must be zero or identical to pCreateInfos[%" PRIu32
2166 "].pViewportState->viewportCount (=%" PRIu32 ").",
2167 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002168 }
2169
Dave Houlton142c4cb2018-10-17 15:04:41 -06002170 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002171 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002172 skip |= LogError(
2173 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002174 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2175 "] "
2176 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2177 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2178 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002179 }
2180
Petr Krausa6103552017-11-16 21:21:58 +01002181 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002182 skip |= LogError(
2183 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002184 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2185 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002186 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2187 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002188 }
2189
2190 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002191 skip |= LogError(
2192 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002193 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2194 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002195 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2196 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002197 }
2198
Jeff Bolz3e71f782018-08-29 23:15:45 -05002199 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002200 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2201 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2202 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002203 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002204 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2205 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2206 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2207 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002208 }
2209
Jeff Bolz9af91c52018-09-01 21:53:57 -05002210 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002211 shading_rate_image_struct->viewportCount > 0 &&
2212 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002213 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002214 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002215 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002216 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2217 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002218 i, i);
2219 }
2220
Chris Mayer328d8212018-12-11 14:16:18 +01002221 if (vp_swizzle_struct) {
2222 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002223 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2224 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2225 " does "
2226 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2227 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002228 }
2229 }
2230
Petr Krausb3fcdb42018-01-09 22:09:09 +01002231 // validate the VkViewports
2232 if (!has_dynamic_viewport && viewport_state.pViewports) {
2233 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2234 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002235 const char *fn_name = "vkCreateGraphicsPipelines";
2236 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2237 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2238 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002239 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002240 }
2241 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002242
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002243 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002244 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2245 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2246 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2247 "VK_NV_clip_space_w_scaling extension is not enabled.",
2248 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002249 }
2250
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002251 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002252 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2253 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2254 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2255 "VK_EXT_discard_rectangles extension is not enabled.",
2256 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002257 }
2258
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002259 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002260 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2261 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2262 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2263 "VK_EXT_sample_locations extension is not enabled.",
2264 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002265 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002266
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002267 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002268 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2269 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2270 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2271 "VK_NV_scissor_exclusive extension is not enabled.",
2272 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002273 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002274
2275 if (coarse_sample_order_struct &&
2276 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2277 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002278 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2279 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2280 "] "
2281 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2282 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2283 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002284 }
2285
2286 if (coarse_sample_order_struct) {
2287 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002288 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002289 }
2290 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002291
2292 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2293 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002294 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2295 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2296 "] "
2297 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2298 ") "
2299 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2300 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002301 }
2302 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002303 skip |= LogError(
2304 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002305 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2306 "] "
2307 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2308 i);
2309 }
2310 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002311 }
2312
2313 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002314 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2315 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2316 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2317 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002318 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002319 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002320 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002321 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2322 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002323 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002324 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002325 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002326 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002327 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002328 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002329 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002330 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2331 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002332
2333 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002334 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002335 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002336 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002337
2338 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002339 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002340 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2341 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2342
2343 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002344 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002345 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2346 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002347 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002348 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002349
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002350 skip |= validate_flags(
2351 "vkCreateGraphicsPipelines",
2352 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2353 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002354 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002355
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002356 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002357 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002358 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2359 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2360
2361 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002362 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002363 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2364 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2365
2366 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002367 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002368 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2369 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2370 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002371 }
John Zulauf7acac592017-11-06 11:15:53 -07002372 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002373 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002374 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2375 "vkCreateGraphicsPipelines(): parameter "
2376 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2377 i);
John Zulauf7acac592017-11-06 11:15:53 -07002378 }
2379 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2380 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2381 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002382 skip |= LogError(
2383 device,
2384
Dave Houlton413a6782018-05-22 13:01:54 -06002385 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002386 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002387 }
2388 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002389
2390 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2391 pCreateInfos[i].pRasterizationState->pNext);
2392
2393 if (line_state) {
2394 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2395 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2396 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2397 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002398 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2399 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2400 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2401 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002402 }
2403 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2404 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002405 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2406 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2407 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2408 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002409 }
2410 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2411 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002412 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2413 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2414 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2415 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002416 }
2417 }
2418 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2419 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2420 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002421 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2422 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2423 "range [1,256].",
2424 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002425 }
2426 }
2427 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002428 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002429 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2430 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002431 skip |=
2432 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2433 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2434 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2435 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002436 }
2437 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2438 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002439 skip |=
2440 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2441 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2442 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2443 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002444 }
2445 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2446 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002447 skip |=
2448 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2449 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2450 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2451 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002452 }
2453 if (line_state->stippledLineEnable) {
2454 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2455 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002456 skip |=
2457 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2458 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2459 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2460 "stippledRectangularLines feature.",
2461 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002462 }
2463 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2464 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002465 skip |=
2466 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2467 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2468 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2469 "stippledBresenhamLines feature.",
2470 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002471 }
2472 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2473 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002474 skip |=
2475 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2476 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2477 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2478 "stippledSmoothLines feature.",
2479 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002480 }
2481 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2482 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002483 skip |=
2484 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2485 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2486 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2487 "stippledRectangularLines and strictLines features.",
2488 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002489 }
2490 }
2491 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002492 }
2493
Petr Krause91f7a12017-12-14 20:57:36 +01002494 bool uses_color_attachment = false;
2495 bool uses_depthstencil_attachment = false;
2496 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002497 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002498 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2499 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002500 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002501 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002502 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002503 }
2504 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002505 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002506 }
Petr Krause91f7a12017-12-14 20:57:36 +01002507 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002508 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002509 }
2510
2511 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002512 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002513 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002514 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002515 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002516 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002517
2518 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002519 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002520 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002521 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002522
2523 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002524 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002525 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2526 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2527
2528 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002529 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002530 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2531 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2532
2533 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002534 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002535 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2536 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002537 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002538
2539 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002540 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002541 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2542 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2543
2544 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002545 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002546 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2547 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2548
2549 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002550 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002551 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2552 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002553 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002554
2555 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002556 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002557 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2558 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002559 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002560
2561 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002562 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002563 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2564 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002565 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002566
2567 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002568 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002569 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2570 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002571 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002572
2573 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002574 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002575 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2576 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002577 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002578
2579 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002580 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002581 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2582 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002583 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002584
2585 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002586 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002587 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2588 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002589 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002590
2591 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002592 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002593 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2594 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002595 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002596
2597 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002598 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002599 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2600 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2601 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002602 }
2603 }
2604
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002605 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002606 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2607
Petr Krause91f7a12017-12-14 20:57:36 +01002608 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002609 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2610 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2611 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2612 pCreateInfos[i].pColorBlendState,
2613 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2614 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2615
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002616 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002617 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002618 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2619 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002620 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2621 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002622 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2623 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002624
2625 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002626 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002627 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002628 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002629
2630 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002631 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002632 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2633 pCreateInfos[i].pColorBlendState->logicOpEnable);
2634
2635 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002636 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002637 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2638 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002639 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002640 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002641
2642 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002643 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2644 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002645 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002646 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002647 ParameterName::IndexVector{i, attachment_index}),
2648 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002649
2650 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002651 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002652 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002653 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002654 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002655 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002656 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002657
2658 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002659 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002660 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002661 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002662 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002663 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002664 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002665
2666 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002667 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002668 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002669 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002670 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002671 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002672 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002673
2674 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002675 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002676 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002677 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002678 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002679 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002680 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002681
2682 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002683 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002684 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002685 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002686 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002687 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002688 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002689
2690 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002691 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002692 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002693 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002694 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002695 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002696 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002697
2698 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002699 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002700 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002701 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002702 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002703 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002704 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002705 }
2706 }
2707
2708 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002709 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002710 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2711 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2712 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002713 }
2714
2715 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2716 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2717 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002718 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002719 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002720 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2721 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002722 }
2723 }
2724 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002725
Petr Kraus9752aae2017-11-24 03:05:50 +01002726 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2727 if (pCreateInfos[i].basePipelineIndex != -1) {
2728 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002729 skip |=
2730 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002731 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002732 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002733 "and pCreateInfos->basePipelineIndex is not -1.",
2734 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002735 }
2736 }
2737
Petr Kraus9752aae2017-11-24 03:05:50 +01002738 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2739 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002740 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002741 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002742 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002743 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2744 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002745 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002746 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002747 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002748 skip |=
2749 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2750 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2751 "index into the pCreateInfos array, of size %d.",
2752 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002753 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002754 }
2755 }
2756
sfricke-samsung898cf222020-05-15 23:10:19 -07002757 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2758 skip |= LogError(
2759 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2760 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2761 i);
2762 }
2763
Petr Kraus9752aae2017-11-24 03:05:50 +01002764 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002765 if (!device_extensions.vk_nv_fill_rectangle) {
2766 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2767 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002768 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2769 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2770 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2771 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002772 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2773 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07002774 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002775 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002776 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2777 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2778 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002779 }
2780 } else {
2781 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2782 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2783 (physical_device_features.fillModeNonSolid == false)) {
2784 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002785 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2786 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002787 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2788 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2789 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002790 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002791 }
Petr Kraus299ba622017-11-24 03:09:03 +01002792
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002793 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002794 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002795 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2796 "The line width state is static (pCreateInfos[%" PRIu32
2797 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2798 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2799 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2800 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002801 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002803 }
2804 }
2805
2806 return skip;
2807}
2808
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002809bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2810 uint32_t createInfoCount,
2811 const VkComputePipelineCreateInfo *pCreateInfos,
2812 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002813 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002814 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002815 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002816 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002817 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002818 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002819 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2820 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002821 skip |=
2822 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2823 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2824 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2825 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002826 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002827
2828 // Make sure compute stage is selected
2829 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002830 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2831 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2832 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002833 }
sourav parmarcd5fb182020-07-17 12:58:44 -07002834
2835 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
2836 skip |=
2837 LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
2838 "vkCreateComputePipelines(): flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
2839 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002840 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002841 return skip;
2842}
2843
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002844bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002845 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002846 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002847
2848 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002849 const auto &features = physical_device_features;
2850 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002851
John Zulauf71968502017-10-26 13:51:15 -06002852 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2853 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002854 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2855 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2856 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2857 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002858 }
2859
2860 // Anistropy cannot be enabled in sampler unless enabled as a feature
2861 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002862 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2863 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2864 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002865 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002866 }
John Zulauf71968502017-10-26 13:51:15 -06002867
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002868 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2869 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002870 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2871 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2872 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2873 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002874 }
2875 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002876 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2877 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2878 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2879 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002880 }
2881 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002882 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2883 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2884 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2885 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002886 }
2887 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2888 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2889 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2890 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002891 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2892 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2893 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2894 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2895 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2896 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002897 }
2898 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002899 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2900 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2901 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002902 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002903 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002904 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2905 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2906 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002907 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002908 }
2909
2910 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2911 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002912 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2913 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002914 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2915 if (sampler_reduction != nullptr) {
2916 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2917 skip |= LogError(
2918 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2919 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2920 }
2921 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002922 }
2923
2924 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2925 // valid VkBorderColor value
2926 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2927 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2928 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002929 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2930 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002931 }
2932
2933 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2934 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002935 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002936 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2937 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2938 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002939 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002940 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2941 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2942 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002943 }
John Zulauf275805c2017-10-26 15:34:49 -06002944
2945 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002946 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002947 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2948 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002949 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2950 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2951 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002952 }
2953 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002954
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002955 // Check for valid Lod range
2956 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002957 skip |=
2958 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2959 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002960 }
2961
2962 // Check mipLodBias to device limit
2963 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002964 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2965 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2966 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002967 }
2968
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002969 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2970 if (sampler_conversion != nullptr) {
2971 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2972 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2973 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2974 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002975 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002976 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002977 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2978 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2979 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2980 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2981 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2982 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2983 }
2984 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002985
2986 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2987 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2988 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2989 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2990 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2991 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2992 }
2993 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2994 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2995 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2996 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2997 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2998 }
2999 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3000 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3001 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3002 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3003 pCreateInfo->minLod, pCreateInfo->maxLod);
3004 }
3005 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3006 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3007 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3008 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3009 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3010 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3011 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3012 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3013 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3014 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3015 }
3016 if (pCreateInfo->anisotropyEnable) {
3017 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3018 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3019 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3020 }
3021 if (pCreateInfo->compareEnable) {
3022 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3023 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3024 "pCreateInfo->compareEnable must be VK_FALSE");
3025 }
3026 if (pCreateInfo->unnormalizedCoordinates) {
3027 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3028 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3029 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3030 }
3031 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003032 }
3033
Tony-LunarG7337b312020-04-15 16:40:25 -06003034 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3035 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3036 if (!device_extensions.vk_ext_custom_border_color) {
3037 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3038 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3039 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3040 }
3041 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
3042 if (!custom_create_info) {
3043 skip |=
3044 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3045 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3046 "struct in pNext chain.\n",
3047 string_VkBorderColor(pCreateInfo->borderColor));
3048 } else {
3049 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3050 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3051 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3052 !FormatIsSampledFloat(custom_create_info->format)))) {
3053 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3054 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3055 "whose type does not match\n",
3056 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3057 ;
3058 }
3059 }
3060 }
3061
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003062 return skip;
3063}
3064
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003065bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3066 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3067 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003068 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003069 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003070
3071 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3072 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3073 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3074 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003075 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3076 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3077 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3078 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3079 ++descriptor_index) {
3080 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003081 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003082 "vkCreateDescriptorSetLayout: required parameter "
3083 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3084 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003085 }
3086 }
3087 }
3088
3089 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3090 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3091 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003092 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3093 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3094 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3095 "values.",
3096 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003097 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003098
3099 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3100 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3101 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3102 skip |=
3103 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3104 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3105 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3106 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3107 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3108 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003109 }
3110 }
3111 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003112 return skip;
3113}
3114
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003115bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3116 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003117 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003118 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3119 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3120 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003121 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3122 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003123}
3124
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003125bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3126 const VkWriteDescriptorSet *pDescriptorWrites,
3127 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003128 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003129
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003130 if (pDescriptorWrites != NULL) {
3131 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3132 // descriptorCount must be greater than 0
3133 if (pDescriptorWrites[i].descriptorCount == 0) {
3134 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003135 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3136 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003137 }
3138
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003139 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3140 if (validateDstSet) {
3141 // dstSet must be a valid VkDescriptorSet handle
3142 skip |= validate_required_handle(vkCallingFunction,
3143 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3144 pDescriptorWrites[i].dstSet);
3145 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003146
3147 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3148 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3149 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3150 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3151 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3152 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3153 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003154 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3155 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003156 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003157 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3158 "%s(): if pDescriptorWrites[%d].descriptorType is "
3159 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3160 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3161 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3162 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003163 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3164 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003165 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3166 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003167 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3168 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003169 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003170 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3171 ParameterName::IndexVector{i, descriptor_index}),
3172 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003173 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003174 }
3175 }
3176 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3177 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3178 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3179 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3180 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3181 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3182 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003183 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003184 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003185 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3186 "%s(): if pDescriptorWrites[%d].descriptorType is "
3187 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3188 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3189 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3190 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003191 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003192 const auto *robustness2_features =
3193 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
3194 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003195 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3196 ++descriptor_index) {
3197 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3198 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3199 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003200 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3201 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003202 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003203 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3204 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003205 }
3206 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003207 }
3208 }
3209 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3210 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003211 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003212 }
3213
3214 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3215 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003216 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3218 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003219 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003220 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003221 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3222 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3223 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003224 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003225 }
3226 }
3227 }
3228 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3229 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003230 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003231 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3232 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003233 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003234 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003235 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3236 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3237 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003238 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003239 }
3240 }
3241 }
3242 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003243 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3244 // or VkWriteDescriptorSetInlineUniformBlockEX
3245 if (pDescriptorWrites[i].pNext) {
3246 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003247 const auto *pnext_struct =
sourav parmara96ab1a2020-04-25 16:28:23 -07003248 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003249 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003250 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3251 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3252 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3253 "accelerationStructureCount %d member equals descriptorCount %d.",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003254 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
sourav parmara96ab1a2020-04-25 16:28:23 -07003255 pDescriptorWrites[i].descriptorCount);
3256 }
3257 // further checks only if we have right structtype
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003258 if (pnext_struct) {
3259 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003260 skip |= LogError(
3261 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3262 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3263 ".",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003264 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003265 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003266 if (pnext_struct->accelerationStructureCount == 0) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003267 skip |= LogError(
3268 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3269 "%s(): accelerationStructureCount must be greater than 0 .");
3270 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003271 const auto *robustness2_features =
3272 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
3273 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3274 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3275 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3276 skip |= LogError(
3277 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3278 "%s(): If the nullDescriptor feature is not enabled, each member of "
3279 "pAccelerationStructures must not be VK_NULL_HANDLE.");
3280 }
3281 }
3282 }
3283 }
3284 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
3285 const auto *pnext_struct =
3286 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
3287 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3288 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3289 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3290 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3291 "accelerationStructureCount %d member equals descriptorCount %d.",
3292 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3293 pDescriptorWrites[i].descriptorCount);
3294 }
3295 // further checks only if we have right structtype
3296 if (pnext_struct) {
3297 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3298 skip |= LogError(
3299 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3300 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3301 ".",
3302 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
3303 }
3304 if (pnext_struct->accelerationStructureCount == 0) {
3305 skip |= LogError(
3306 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
3307 "%s(): accelerationStructureCount must be greater than 0 .");
3308 }
3309 const auto *robustness2_features =
3310 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
3311 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3312 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3313 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3314 skip |= LogError(
3315 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3316 "%s(): If the nullDescriptor feature is not enabled, each member of "
3317 "pAccelerationStructures must not be VK_NULL_HANDLE.");
3318 }
3319 }
3320 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003321 }
3322 }
3323 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003324 }
3325 }
3326 return skip;
3327}
3328
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003329bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3330 const VkWriteDescriptorSet *pDescriptorWrites,
3331 uint32_t descriptorCopyCount,
3332 const VkCopyDescriptorSet *pDescriptorCopies) const {
3333 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3334}
3335
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003336bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003337 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003338 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003339 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3340}
3341
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003342bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3343 const VkAllocationCallbacks *pAllocator,
3344 VkRenderPass *pRenderPass) const {
3345 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3346}
3347
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003348bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003349 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003350 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003351 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3352}
3353
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003354bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3355 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003356 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003357 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003358
3359 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3360 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3361 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003362 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3363 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003364 return skip;
3365}
3366
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003367bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003368 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003369 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003370
3371 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3372 const char *cmd_name = "vkBeginCommandBuffer";
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003373 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003374
Petr Krause7bb9e82019-08-11 21:34:43 +02003375 // Implicit VUs
3376 // validate only sType here; pointer has to be validated in core_validation
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003377 const bool k_not_required = false;
3378 const char *k_no_vuid = nullptr;
Petr Krause7bb9e82019-08-11 21:34:43 +02003379 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003380 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
Petr Krause7bb9e82019-08-11 21:34:43 +02003381 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003382
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003383 if (info) {
3384 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
Petr Krause7bb9e82019-08-11 21:34:43 +02003385 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
3386 skip |= validate_struct_pnext(
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003387 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", info->pNext,
3388 ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info), allowed_structs_vk_command_buffer_inheritance_info,
sfricke-samsung32a27362020-02-28 09:06:42 -08003389 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
3390 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003391
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003392 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003393
Petr Krause7bb9e82019-08-11 21:34:43 +02003394 // Explicit VUs
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003395 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003396 skip |= LogError(
3397 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02003398 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3399 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003400 }
Petr Krause7bb9e82019-08-11 21:34:43 +02003401
3402 if (physical_device_features.inheritedQueries) {
3403 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003404 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06003405 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02003406 } else { // !inheritedQueries
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003407 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003408 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02003409 }
3410
3411 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003412 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003413 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003414 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003415 } else { // !pipelineStatisticsQuery
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003416 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
Petr Krause7bb9e82019-08-11 21:34:43 +02003417 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003418 }
Petr Kraus139757b2019-08-15 17:19:33 +02003419
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003420 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Petr Kraus139757b2019-08-15 17:19:33 +02003421 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003422 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003423 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3424 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003425 skip |= LogError(
3426 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003427 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3428 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3429 }
3430 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003431 }
3432
3433 return skip;
3434}
3435
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003436bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003437 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003438 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003440 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003441 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003442 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3443 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3444 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003445 }
3446 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003447 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3448 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3449 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003450 }
3451 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003452 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003453 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003454 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3455 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3456 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3457 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003458 }
3459 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003460
3461 if (pViewports) {
3462 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3463 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003464 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003465 skip |= manual_PreCallValidateViewport(
3466 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003467 }
3468 }
3469
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003470 return skip;
3471}
3472
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003473bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003474 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003475 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003476
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003477 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003478 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003479 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3480 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3481 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003482 }
3483 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003484 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3485 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3486 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003487 }
3488 } else { // multiViewport enabled
3489 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003490 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003491 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3492 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3493 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3494 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003495 }
3496 }
3497
Petr Kraus6260f0a2018-02-27 21:15:55 +01003498 if (pScissors) {
3499 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3500 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003501
Petr Kraus6260f0a2018-02-27 21:15:55 +01003502 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003503 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3504 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3505 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003506 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003507
Petr Kraus6260f0a2018-02-27 21:15:55 +01003508 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003509 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3510 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3511 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003512 }
3513
3514 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3515 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003516 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3517 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3518 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3519 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003520 }
3521
3522 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3523 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003524 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3525 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3526 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3527 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003528 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003529 }
3530 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003531
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003532 return skip;
3533}
3534
Jeff Bolz5c801d12019-10-09 10:38:45 -05003535bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003536 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003537
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003538 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003539 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3540 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003541 }
3542
3543 return skip;
3544}
3545
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003546bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003547 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003548 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003549
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003550 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003551 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003552 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3553 }
3554 if (drawCount > device_limits.maxDrawIndirectCount) {
3555 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
3556 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3557 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003558 }
3559 return skip;
3560}
3561
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003562bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003563 VkDeviceSize offset, uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003564 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003565 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003566 skip |=
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003567 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003568 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3569 }
3570 if (drawCount > device_limits.maxDrawIndirectCount) {
3571 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
3572 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3573 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003574 }
3575 return skip;
3576}
3577
sfricke-samsungf692b972020-05-02 08:00:45 -07003578bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3579 VkDeviceSize countBufferOffset, bool khr) const {
3580 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003581 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003582 if (offset & 3) {
3583 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003584 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003585 }
3586
3587 if (countBufferOffset & 3) {
3588 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003589 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003590 countBufferOffset);
3591 }
3592 return skip;
3593}
3594
3595bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3596 VkDeviceSize offset, VkBuffer countBuffer,
3597 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3598 uint32_t stride) const {
3599 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3600}
3601
3602bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3603 VkDeviceSize offset, VkBuffer countBuffer,
3604 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3605 uint32_t stride) const {
3606 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3607}
3608
3609bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3610 VkDeviceSize countBufferOffset, bool khr) const {
3611 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003612 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003613 if (offset & 3) {
3614 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003615 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003616 }
3617
3618 if (countBufferOffset & 3) {
3619 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003620 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003621 countBufferOffset);
3622 }
3623 return skip;
3624}
3625
3626bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3627 VkDeviceSize offset, VkBuffer countBuffer,
3628 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3629 uint32_t stride) const {
3630 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3631}
3632
3633bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3634 VkDeviceSize offset, VkBuffer countBuffer,
3635 VkDeviceSize countBufferOffset,
3636 uint32_t maxDrawCount, uint32_t stride) const {
3637 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3638}
3639
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003640bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3641 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003642 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003643 bool skip = false;
3644 for (uint32_t rect = 0; rect < rectCount; rect++) {
3645 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003646 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3647 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003648 }
sfricke-samsung10867682020-04-25 02:20:39 -07003649 if (pRects[rect].rect.extent.width == 0) {
3650 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3651 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3652 }
3653 if (pRects[rect].rect.extent.height == 0) {
3654 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3655 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3656 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003657 }
3658 return skip;
3659}
3660
Andrew Fobel3abeb992020-01-20 16:33:22 -05003661bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3662 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3663 VkImageFormatProperties2 *pImageFormatProperties,
3664 const char *apiName) const {
3665 bool skip = false;
3666
3667 if (pImageFormatInfo != nullptr) {
3668 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3669 if (image_stencil_struct != nullptr) {
3670 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3671 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3672 // No flags other than the legal attachment bits may be set
3673 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3674 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003675 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3676 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3677 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3678 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3679 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003680 }
3681 }
3682 }
3683 }
3684
3685 return skip;
3686}
3687
3688bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3689 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3690 VkImageFormatProperties2 *pImageFormatProperties) const {
3691 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3692 "vkGetPhysicalDeviceImageFormatProperties2");
3693}
3694
3695bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3696 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3697 VkImageFormatProperties2 *pImageFormatProperties) const {
3698 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3699 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3700}
3701
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03003702bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
3703 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
3704 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
3705 bool skip = false;
3706
3707 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
3708 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
3709 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
3710 }
3711
3712 return skip;
3713}
3714
sfricke-samsung3999ef62020-02-09 17:05:59 -08003715bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3716 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3717 bool skip = false;
3718
3719 if (pRegions != nullptr) {
3720 for (uint32_t i = 0; i < regionCount; i++) {
3721 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003722 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3723 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003724 }
3725 }
3726 }
3727 return skip;
3728}
3729
Jeff Leger178b1e52020-10-05 12:22:23 -04003730bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
3731 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
3732 bool skip = false;
3733
3734 if (pCopyBufferInfo->pRegions != nullptr) {
3735 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
3736 if (pCopyBufferInfo->pRegions[i].size == 0) {
3737 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
3738 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
3739 }
3740 }
3741 }
3742 return skip;
3743}
3744
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003745bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003746 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3747 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003748 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003749
3750 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003751 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3752 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3753 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003754 }
3755
3756 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003757 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3758 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3759 "), must be greater than zero and less than or equal to 65536.",
3760 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003761 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003762 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3763 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3764 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003765 }
3766 return skip;
3767}
3768
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003769bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003770 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003771 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003772
3773 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003774 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3775 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3776 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003777 }
3778
3779 if (size != VK_WHOLE_SIZE) {
3780 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003781 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003782 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3783 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003784 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003785 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3786 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003787 }
3788 }
3789 return skip;
3790}
3791
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003792bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003793 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003794 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003795 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003796
3797 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003798 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3799 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3800 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3801 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003802 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3803 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3804 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003805 }
3806
3807 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3808 // queueFamilyIndexCount uint32_t values
3809 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003810 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3811 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3812 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3813 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003814 }
3815 }
3816
Dave Houlton413a6782018-05-22 13:01:54 -06003817 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003818 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003819 }
3820
3821 return skip;
3822}
3823
Jeff Bolz5c801d12019-10-09 10:38:45 -05003824bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003825 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003826
3827 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003828 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3829 if (present_regions) {
3830 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003831 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003832 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3833 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07003834 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003835 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3836 "extension swapchainCount is %i. These values must be equal.",
3837 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003838 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003839 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003840 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3841 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003842 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3843 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3844 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003845 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003846 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003847 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003848 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003849 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003850 }
3851 }
3852
3853 return skip;
3854}
3855
sfricke-samsung5c1b7392020-12-13 22:17:15 -08003856bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
3857 const VkDisplayModeCreateInfoKHR *pCreateInfo,
3858 const VkAllocationCallbacks *pAllocator,
3859 VkDisplayModeKHR *pMode) const {
3860 bool skip = false;
3861
3862 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
3863 if (display_mode_parameters.visibleRegion.width == 0) {
3864 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
3865 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
3866 }
3867 if (display_mode_parameters.visibleRegion.height == 0) {
3868 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
3869 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
3870 }
3871 if (display_mode_parameters.refreshRate == 0) {
3872 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
3873 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
3874 }
3875
3876 return skip;
3877}
3878
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003879#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003880bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3881 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3882 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003883 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003884 bool skip = false;
3885
3886 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003887 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3888 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003889 }
3890
3891 return skip;
3892}
3893#endif // VK_USE_PLATFORM_WIN32_KHR
3894
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003895bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003896 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003897 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003898 bool skip = false;
3899
3900 if (pCreateInfo) {
3901 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003902 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3903 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003904 }
3905
3906 if (pCreateInfo->pPoolSizes) {
3907 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3908 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003909 skip |= LogError(
3910 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003911 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003912 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003913 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3914 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003915 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3916 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3917 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3918 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3919 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003920 }
Petr Krausc8655be2017-09-27 18:56:51 +02003921 }
3922 }
3923 }
3924
3925 return skip;
3926}
3927
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003928bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003929 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003930 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003931
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003932 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003933 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003934 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3935 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3936 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003937 }
3938
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003939 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003940 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003941 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3942 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3943 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003944 }
3945
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003946 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003947 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003948 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3949 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3950 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003951 }
3952
3953 return skip;
3954}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003955
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003956bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003957 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003958 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003959
3960 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003961 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3962 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003963 }
3964 return skip;
3965}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003966
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003967bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3968 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003969 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003970 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003971
3972 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003973 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003974 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003975 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3976 "vkCmdDispatch(): baseGroupX (%" PRIu32
3977 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3978 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003979 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003980 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3981 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3982 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3983 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003984 }
3985
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003986 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003987 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003988 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3989 "vkCmdDispatch(): baseGroupY (%" PRIu32
3990 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3991 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003992 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003993 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3994 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3995 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3996 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003997 }
3998
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003999 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004000 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004001 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4002 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4003 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4004 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004005 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004006 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4007 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4008 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4009 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004010 }
4011
4012 return skip;
4013}
4014
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004015bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4016 VkPipelineBindPoint pipelineBindPoint,
4017 VkPipelineLayout layout, uint32_t set,
4018 uint32_t descriptorWriteCount,
4019 const VkWriteDescriptorSet *pDescriptorWrites) const {
4020 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4021}
4022
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004023bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4024 uint32_t firstExclusiveScissor,
4025 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004026 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004027 bool skip = false;
4028
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004029 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004030 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004031 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004032 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4033 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4034 ") is not 0.",
4035 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004036 }
4037 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004038 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004039 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4040 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4041 ") is not 1.",
4042 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004043 }
4044 } else { // multiViewport enabled
4045 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004046 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004047 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4048 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4049 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4050 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004051 }
4052 }
4053
Jeff Bolz3e71f782018-08-29 23:15:45 -05004054 if (pExclusiveScissors) {
4055 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4056 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4057
4058 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004059 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4060 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4061 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004062 }
4063
4064 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004065 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4066 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4067 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004068 }
4069
4070 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4071 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004072 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4073 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4074 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4075 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004076 }
4077
4078 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4079 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004080 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4081 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4082 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4083 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004084 }
4085 }
4086 }
4087
4088 return skip;
4089}
4090
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004091bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4092 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004093 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004094 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004095 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4096 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4097 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4098 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4099 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4100 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004101 }
4102
4103 return skip;
4104}
4105
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004106bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4107 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004108 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004109 bool skip = false;
4110
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004111 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004112 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004113 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004114 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4115 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4116 ") is not 0.",
4117 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004118 }
4119 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004120 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004121 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4122 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4123 ") is not 1.",
4124 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004125 }
4126 }
4127
Jeff Bolz9af91c52018-09-01 21:53:57 -05004128 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004129 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004130 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4131 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4132 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4133 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004134 }
4135
4136 return skip;
4137}
4138
Jeff Bolz5c801d12019-10-09 10:38:45 -05004139bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4140 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4141 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004142 bool skip = false;
4143
Dave Houlton142c4cb2018-10-17 15:04:41 -06004144 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004145 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4146 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4147 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004148 }
4149
4150 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004151 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004152 }
4153
4154 return skip;
4155}
4156
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004157bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004158 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004159 bool skip = false;
4160
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004161 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004162 skip |= LogError(
4163 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004164 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4165 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004166 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004167 }
4168
4169 return skip;
4170}
4171
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004172bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4173 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004174 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004175 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004176 static const int condition_multiples = 0b0011;
4177 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004178 skip |= LogError(
4179 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004180 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004181 }
Lockee1c22882019-06-10 16:02:54 -06004182 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004183 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4184 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4185 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4186 stride);
Lockee1c22882019-06-10 16:02:54 -06004187 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004188 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004189 skip |= LogError(
4190 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4191 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004192 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004193 if (drawCount > device_limits.maxDrawIndirectCount) {
4194 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
4195 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
4196 device_limits.maxDrawIndirectCount);
4197 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004198 return skip;
4199}
4200
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004201bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4202 VkDeviceSize offset, VkBuffer countBuffer,
4203 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004204 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004205 bool skip = false;
4206
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004207 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004208 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4209 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4210 "), is not a multiple of 4.",
4211 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004212 }
4213
4214 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004215 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4216 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4217 "), is not a multiple of 4.",
4218 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004219 }
4220
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004221 return skip;
4222}
4223
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004224bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004225 const VkAllocationCallbacks *pAllocator,
4226 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004227 bool skip = false;
4228
4229 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4230 if (pCreateInfo != nullptr) {
4231 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4232 // VkQueryPipelineStatisticFlagBits values
4233 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4234 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004235 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4236 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4237 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4238 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004239 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004240 if (pCreateInfo->queryCount == 0) {
4241 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4242 "vkCreateQueryPool(): queryCount must be greater than zero.");
4243 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004244 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004245 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004246}
4247
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004248bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4249 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004250 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004251 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4252 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004253}
4254
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004255void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004256 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4257 VkResult result) {
4258 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004259 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004260}
4261
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004262void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004263 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4264 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004265 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004266 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004267 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004268}
4269
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004270void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4271 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004272 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004273 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004274 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004275}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004276
4277bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004278 const VkAllocationCallbacks *pAllocator,
4279 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004280 bool skip = false;
4281
4282 if (pAllocateInfo) {
4283 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
4284 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004285 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4286 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004287 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004288
4289 VkMemoryAllocateFlags flags = 0;
4290 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
4291 if (flags_info) {
4292 flags = flags_info->flags;
4293 }
4294
4295 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
4296 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
4297 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004298 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4299 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
4300 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004301 }
4302
4303#ifdef VK_USE_PLATFORM_WIN32_KHR
4304 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
4305#endif
4306 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4307 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
4308#ifdef VK_USE_PLATFORM_ANDROID_KHR
4309 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
4310#endif
4311
4312 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004313 skip |= LogError(
4314 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004315 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4316 }
4317 if (
4318#ifdef VK_USE_PLATFORM_WIN32_KHR
4319 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4320#endif
4321 (import_memory_fd && import_memory_fd->handleType) ||
4322#ifdef VK_USE_PLATFORM_ANDROID_KHR
4323 (import_memory_ahb && import_memory_ahb->buffer) ||
4324#endif
4325 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004326 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4327 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004328 }
4329 }
4330
4331 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004332 VkBool32 capture_replay = false;
4333 VkBool32 buffer_device_address = false;
4334 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
4335 if (vulkan_12_features) {
4336 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4337 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4338 } else {
4339 const auto *bda_features =
4340 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4341 if (bda_features) {
4342 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4343 buffer_device_address = bda_features->bufferDeviceAddress;
4344 }
4345 }
4346 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004347 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4348 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4349 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004350 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004351 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004352 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4353 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004354 }
4355 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004356 }
4357 return skip;
4358}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004359
Jason Macnak192fa0e2019-07-26 15:07:16 -07004360bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004361 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004362 bool skip = false;
4363
4364 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4365 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4366 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004367 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004368 } else {
4369 uint32_t vertex_component_size = 0;
4370 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4371 vertex_component_size = 4;
4372 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4373 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4374 vertex_component_size = 2;
4375 }
4376 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004377 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004378 }
4379 }
4380
4381 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4382 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004383 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004384 } else {
4385 uint32_t index_element_size = 0;
4386 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4387 index_element_size = 4;
4388 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4389 index_element_size = 2;
4390 }
4391 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004392 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004393 }
4394 }
4395 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4396 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004397 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004398 }
4399 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004400 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004401 }
4402 }
4403
4404 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004405 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004406 }
4407
4408 return skip;
4409}
4410
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004411bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4412 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004413 bool skip = false;
4414
4415 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004416 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004417 }
4418 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004419 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004420 }
4421
4422 return skip;
4423}
4424
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004425bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4426 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004427 bool skip = false;
4428 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004429 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004430 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004431 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004432 }
4433 return skip;
4434}
4435
4436bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004437 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004438 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004439 bool skip = false;
4440 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004441 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4442 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4443 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004444 }
4445 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004446 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4447 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4448 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004449 }
4450 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4451 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004452 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4453 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4454 "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 -07004455 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004456 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004457 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004458 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4459 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004460 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4461 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004462 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004463 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004464 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4465 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4466 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004467 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004468 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004469 uint64_t total_triangle_count = 0;
4470 for (uint32_t i = 0; i < info.geometryCount; i++) {
4471 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004472
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004473 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004474
Jason Macnak5c954952019-07-09 15:46:12 -07004475 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4476 continue;
4477 }
4478 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4479 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004480 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004481 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4482 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4483 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004484 }
4485 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004486 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4487 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4488 for (uint32_t i = 1; i < info.geometryCount; i++) {
4489 const VkGeometryNV &geometry = info.pGeometries[i];
4490 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004491 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004492 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4493 "info.pGeometries[0].geometryType.",
4494 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004495 }
4496 }
4497 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004498 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4499 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4500 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4501 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4502 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4503 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4504 }
4505 }
4506 skip |=
4507 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004508 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004509 return skip;
4510}
4511
Ricardo Garciaa4935972019-02-21 17:43:18 +01004512bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4513 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004514 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004515 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004516 if (pCreateInfo) {
4517 if ((pCreateInfo->compactedSize != 0) &&
4518 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004519 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4520 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4521 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4522 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004523 }
Jason Macnak5c954952019-07-09 15:46:12 -07004524
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004525 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004526 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004527 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004528 return skip;
4529}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004530
Jeff Bolz5c801d12019-10-09 10:38:45 -05004531bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4532 const VkAccelerationStructureInfoNV *pInfo,
4533 VkBuffer instanceData, VkDeviceSize instanceOffset,
4534 VkBool32 update, VkAccelerationStructureNV dst,
4535 VkAccelerationStructureNV src, VkBuffer scratch,
4536 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004537 bool skip = false;
4538
4539 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004540 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004541 }
4542
4543 return skip;
4544}
4545
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004546bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4547 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4548 VkAccelerationStructureKHR *pAccelerationStructure) const {
4549 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004550 const auto *acceleration_structure_features =
4551 lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
4552 if (!acceleration_structure_features ||
4553 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
4554 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
4555 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
4556 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004557 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004558 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
4559 (!acceleration_structure_features ||
4560 (acceleration_structure_features && acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07004561 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07004562 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
4563 "vkCreateAccelerationStructureKHR(): If createFlags includes "
4564 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
4565 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07004566 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004567 if (pCreateInfo->deviceAddress &&
4568 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
4569 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
4570 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
4571 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
4572 }
4573 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
4574 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
4575 "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset);
4576 }
sourav parmar83c31b12020-05-06 12:30:54 -07004577 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004578 return skip;
4579}
4580
Jason Macnak5c954952019-07-09 15:46:12 -07004581bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4582 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004583 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004584 bool skip = false;
4585 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004586 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4587 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004588 }
4589 return skip;
4590}
4591
sourav parmarcd5fb182020-07-17 12:58:44 -07004592bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
4593 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
4594 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4595 bool skip = false;
4596 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
4597 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
4598 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
4599 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
4600 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
4601 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
4602 }
4603 return skip;
4604}
4605
Peter Chen85366392019-05-14 15:20:11 -04004606bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4607 uint32_t createInfoCount,
4608 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4609 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004610 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004611 bool skip = false;
4612
4613 for (uint32_t i = 0; i < createInfoCount; i++) {
4614 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4615 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004616 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004617 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4618 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4619 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4620 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004621 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004622
4623 const auto *pipeline_cache_contol_features =
4624 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4625 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4626 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4627 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4628 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4629 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4630 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4631 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4632 }
4633 }
4634
sourav parmarf4a78252020-04-10 13:04:21 -07004635 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4636 skip |=
4637 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4638 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4639 }
4640 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4641 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4642 skip |=
4643 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4644 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4645 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4646 }
4647 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4648 if (pCreateInfos[i].basePipelineIndex != -1) {
4649 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4650 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4651 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4652 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4653 "and pCreateInfos->basePipelineIndex is not -1.");
4654 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004655 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004656 skip |=
4657 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4658 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4659 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4660 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4661 "that element.");
4662 }
sourav parmarf4a78252020-04-10 13:04:21 -07004663 }
4664 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004665 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004666 skip |=
4667 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4668 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4669 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4670 "commands pCreateInfos parameter.");
4671 }
4672 } else {
4673 if (pCreateInfos[i].basePipelineIndex != -1) {
4674 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4675 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4676 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4677 }
4678 }
4679 }
4680 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4681 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4682 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4683 }
4684 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4685 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4686 "vkCreateRayTracingPipelinesNV: flags must not include "
4687 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4688 }
4689 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4690 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4691 "vkCreateRayTracingPipelinesNV: flags must not include "
4692 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4693 }
4694 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4695 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4696 "vkCreateRayTracingPipelinesNV: flags must not include "
4697 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4698 }
4699 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4700 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4701 "vkCreateRayTracingPipelinesNV: flags must not include "
4702 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4703 }
4704 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4705 skip |= LogError(
4706 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4707 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4708 }
4709 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4710 skip |= LogError(
4711 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4712 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4713 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004714 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
4715 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
4716 "vkCreateRayTracingPipelinesNV: flags must not include "
4717 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4718 }
4719 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4720 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
4721 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
4722 }
Peter Chen85366392019-05-14 15:20:11 -04004723 }
4724
4725 return skip;
4726}
4727
sourav parmarcd5fb182020-07-17 12:58:44 -07004728bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
4729 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
4730 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004731 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004732 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
4733 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
4734 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
4735 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07004736 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004737 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004738 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
4739 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4740 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
4741 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4742 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4743 }
4744 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4745 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
4746 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4747 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
4748 }
4749 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004750 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4751 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4752 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07004753 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
4754 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
4755 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004756 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4757 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4758 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004759 const auto *pipeline_cache_contol_features =
4760 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4761 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4762 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4763 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4764 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07004765 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07004766 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4767 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4768 }
4769 }
sourav parmarf4a78252020-04-10 13:04:21 -07004770 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004771 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4772 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07004773 }
4774 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004775 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07004776 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07004777 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
4778 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004779 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004780 }
4781 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4782 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
4783 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07004784 }
4785 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4786 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4787 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4788 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4789 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4790 skip |= LogError(
4791 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07004792 "vkCreateRayTracingPipelinesKHR: If flags includes "
4793 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004794 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4795 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4796 "must not be VK_SHADER_UNUSED_KHR");
4797 }
4798 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4799 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4800 skip |= LogError(
4801 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07004802 "vkCreateRayTracingPipelinesKHR: If flags includes "
4803 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004804 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4805 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4806 "element must not be VK_SHADER_UNUSED_KHR");
4807 }
4808 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004809 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
4810 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
4811 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
4812 skip |= LogError(
4813 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
4814 "vkCreateRayTracingPipelinesKHR: If "
4815 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
4816 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
4817 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4818 }
4819 }
sourav parmarf4a78252020-04-10 13:04:21 -07004820 }
4821 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4822 if (pCreateInfos[i].basePipelineIndex != -1) {
4823 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4824 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07004825 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07004826 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4827 "and pCreateInfos->basePipelineIndex is not -1.");
4828 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004829 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004830 skip |=
4831 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4832 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4833 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4834 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4835 "element.");
4836 }
sourav parmarf4a78252020-04-10 13:04:21 -07004837 }
4838 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004839 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004840 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07004841 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07004842 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4843 "commands pCreateInfos parameter %d.",
4844 pCreateInfos[i].basePipelineIndex, createInfoCount);
4845 }
4846 } else {
4847 if (pCreateInfos[i].basePipelineIndex != -1) {
4848 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07004849 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07004850 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4851 }
4852 }
4853 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004854 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
4855 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
4856 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
4857 "vkCreateRayTracingPipelinesKHR: If flags includes "
4858 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
4859 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
sourav parmarf4a78252020-04-10 13:04:21 -07004860 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004861 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
4862 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
4863 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
4864 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
4865 "pLibraryInfo and pLibraryInterface must be NULL.");
sourav parmarf4a78252020-04-10 13:04:21 -07004866 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004867 if (pCreateInfos[i].pLibraryInfo) {
4868 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
4869 if (pCreateInfos[i].stageCount == 0) {
4870 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
4871 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
4872 "stageCount must not be 0.");
4873 }
4874 if (pCreateInfos[i].groupCount == 0) {
4875 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
4876 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
4877 "groupCount must not be 0.");
4878 }
4879 } else {
4880 if (pCreateInfos[i].pLibraryInterface == NULL) {
4881 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
4882 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
4883 "is greater than 0, its "
4884 "pLibraryInterface member must not be NULL.");
4885 }
4886 }
4887 }
4888 if (pCreateInfos[i].pLibraryInterface) {
4889 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
4890 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
4891 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
4892 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
4893 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
4894 }
4895 }
4896 if (deferredOperation != VK_NULL_HANDLE) {
4897 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
4898 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
4899 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
4900 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07004901 }
4902 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004903 }
4904
4905 return skip;
4906}
4907
Mike Schuchardt21638df2019-03-16 10:52:02 -07004908#ifdef VK_USE_PLATFORM_WIN32_KHR
4909bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4910 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004911 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004912 bool skip = false;
4913 if (!device_extensions.vk_khr_swapchain)
4914 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4915 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4916 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4917 if (!device_extensions.vk_khr_surface)
4918 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4919 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4920 skip |=
4921 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4922 if (!device_extensions.vk_ext_full_screen_exclusive)
4923 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4924 skip |= validate_struct_type(
4925 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4926 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4927 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4928 if (pSurfaceInfo != NULL) {
4929 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4930 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4931 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4932
4933 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4934 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4935 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4936 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004937 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4938 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004939
4940 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4941 }
4942 return skip;
4943}
4944#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004945
4946bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4947 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004948 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004949 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4950 bool skip = false;
4951 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4952 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4953 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4954 }
4955 return skip;
4956}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004957
4958bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004959 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004960 bool skip = false;
4961
4962 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004963 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4964 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004965 }
4966
4967 return skip;
4968}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004969
4970bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004971 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004972 bool skip = false;
4973
4974 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004975 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4976 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004977 }
4978
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004979 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004980 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004981 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4982 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004983 }
4984
4985 return skip;
4986}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004987
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004988bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4989 uint32_t bindingCount, const VkBuffer *pBuffers,
4990 const VkDeviceSize *pOffsets) const {
4991 bool skip = false;
4992 if (firstBinding > device_limits.maxVertexInputBindings) {
4993 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4994 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4995 device_limits.maxVertexInputBindings);
4996 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4997 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4998 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4999 "maxVertexInputBindings (%u)",
5000 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5001 }
5002
Jeff Bolz165818a2020-05-08 11:19:03 -05005003 for (uint32_t i = 0; i < bindingCount; ++i) {
5004 if (pBuffers[i] == VK_NULL_HANDLE) {
5005 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
5006 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5007 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5008 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5009 } else {
5010 if (pOffsets[i] != 0) {
5011 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5012 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5013 }
5014 }
5015 }
5016 }
5017
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005018 return skip;
5019}
5020
Mark Lobodzinski84988402019-09-11 15:27:30 -06005021bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005022 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005023 bool skip = false;
5024 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005025 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5026 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005027 }
5028 return skip;
5029}
5030
5031bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005032 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005033 bool skip = false;
5034 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005035 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5036 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005037 }
5038 return skip;
5039}
Petr Kraus3d720392019-11-13 02:52:39 +01005040
5041bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5042 VkSemaphore semaphore, VkFence fence,
5043 uint32_t *pImageIndex) const {
5044 bool skip = false;
5045
5046 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005047 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5048 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005049 }
5050
5051 return skip;
5052}
5053
5054bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5055 uint32_t *pImageIndex) const {
5056 bool skip = false;
5057
5058 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005059 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5060 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005061 }
5062
5063 return skip;
5064}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005065
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005066bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5067 uint32_t firstBinding, uint32_t bindingCount,
5068 const VkBuffer *pBuffers,
5069 const VkDeviceSize *pOffsets,
5070 const VkDeviceSize *pSizes) const {
5071 bool skip = false;
5072
5073 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5074 for (uint32_t i = 0; i < bindingCount; ++i) {
5075 if (pOffsets[i] & 3) {
5076 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5077 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5078 }
5079 }
5080
5081 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5082 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5083 "%s: The firstBinding(%" PRIu32
5084 ") index is greater than or equal to "
5085 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5086 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5087 }
5088
5089 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5090 skip |=
5091 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5092 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5093 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5094 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5095 }
5096
5097 for (uint32_t i = 0; i < bindingCount; ++i) {
5098 // pSizes is optional and may be nullptr.
5099 if (pSizes != nullptr) {
5100 if (pSizes[i] != VK_WHOLE_SIZE &&
5101 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5102 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5103 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5104 ") is not VK_WHOLE_SIZE and is greater than "
5105 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5106 cmd_name, i, pSizes[i]);
5107 }
5108 }
5109 }
5110
5111 return skip;
5112}
5113
5114bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5115 uint32_t firstCounterBuffer,
5116 uint32_t counterBufferCount,
5117 const VkBuffer *pCounterBuffers,
5118 const VkDeviceSize *pCounterBufferOffsets) const {
5119 bool skip = false;
5120
5121 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5122 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5123 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5124 "%s: The firstCounterBuffer(%" PRIu32
5125 ") index is greater than or equal to "
5126 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5127 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5128 }
5129
5130 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5131 skip |=
5132 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5133 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5134 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5135 cmd_name, firstCounterBuffer, counterBufferCount,
5136 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5137 }
5138
5139 return skip;
5140}
5141
5142bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5143 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5144 const VkBuffer *pCounterBuffers,
5145 const VkDeviceSize *pCounterBufferOffsets) const {
5146 bool skip = false;
5147
5148 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5149 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5150 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5151 "%s: The firstCounterBuffer(%" PRIu32
5152 ") index is greater than or equal to "
5153 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5154 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5155 }
5156
5157 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5158 skip |=
5159 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5160 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5161 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5162 cmd_name, firstCounterBuffer, counterBufferCount,
5163 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5164 }
5165
5166 return skip;
5167}
5168
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005169bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5170 uint32_t firstInstance, VkBuffer counterBuffer,
5171 VkDeviceSize counterBufferOffset,
5172 uint32_t counterOffset, uint32_t vertexStride) const {
5173 bool skip = false;
5174
5175 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005176 skip |= LogError(
5177 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005178 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5179 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5180 }
5181
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005182 if ((counterOffset % 4) != 0) {
5183 // TODO - Update when header are updated
5184 skip |= LogError(commandBuffer, "UNASSIGNED-vkCmdDrawIndirectByteCountEXT-offset",
5185 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5186 }
5187
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005188 return skip;
5189}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005190
5191bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5192 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5193 const VkAllocationCallbacks *pAllocator,
5194 VkSamplerYcbcrConversion *pYcbcrConversion,
5195 const char *apiName) const {
5196 bool skip = false;
5197
5198 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07005199 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005200 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005201 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
5202 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5203 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005204 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005205 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005206 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005207
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005208#ifdef VK_USE_PLATFORM_ANDROID_KHR
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005209 const VkExternalFormatANDROID *external_format_android = lvl_find_in_chain<VkExternalFormatANDROID>(pCreateInfo);
5210 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005211#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005212 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005213#endif
5214
sfricke-samsung1a72f942020-07-25 12:09:18 -07005215 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005216
5217 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005218 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005219 const VkComponentMapping components = pCreateInfo->components;
5220 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5221 if (FormatIsXChromaSubsampled(format) == true) {
5222 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5223 skip |=
5224 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005225 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5226 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005227 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005228 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005229
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005230 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5231 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5232 skip |= LogError(
5233 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5234 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5235 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5236 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5237 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005238
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005239 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5240 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5241 skip |=
5242 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005243 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5244 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005245 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005246 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005247
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005248 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5249 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5250 skip |=
5251 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005252 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5253 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005254 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005255 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005256
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005257 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005258 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5259 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5260 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005261 skip |=
5262 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005263 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5264 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005265 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5266 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005267 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005268 }
5269
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005270 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5271 // Checks same VU multiple ways in order to give a more useful error message
5272 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5273 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5274 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5275 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5276 skip |= LogError(
5277 device, vuid,
5278 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5279 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5280 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5281 string_VkComponentSwizzle(components.b));
5282 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005283
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005284 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5285 // 4 channel format = no issue
5286 // 3 = no [a]
5287 // 2 = no [b,a]
5288 // 1 = no [g,b,a]
5289 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5290 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5291
5292 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5293 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5294 skip |= LogError(device, vuid,
5295 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5296 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5297 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5298 string_VkComponentSwizzle(components.b));
5299 } else if ((channels < 3) &&
5300 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5301 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5302 skip |= LogError(device, vuid,
5303 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5304 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5305 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5306 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5307 string_VkComponentSwizzle(components.b));
5308 } else if ((channels < 2) &&
5309 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5310 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5311 skip |= LogError(device, vuid,
5312 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5313 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5314 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5315 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5316 string_VkComponentSwizzle(components.b));
5317 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005318 }
5319 }
5320
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005321 return skip;
5322}
5323
5324bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5325 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5326 const VkAllocationCallbacks *pAllocator,
5327 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5328 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5329 "vkCreateSamplerYcbcrConversion");
5330}
5331
5332bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5333 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5334 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5335 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5336 "vkCreateSamplerYcbcrConversionKHR");
5337}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005338
5339bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5340 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5341 bool skip = false;
5342 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5343 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5344
5345 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005346 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5347 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5348 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5349 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5350 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005351 }
5352 return skip;
5353}
sourav parmara96ab1a2020-04-25 16:28:23 -07005354
5355bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005356 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005357 bool skip = false;
5358 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5359 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5360 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5361 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005362 const auto *acc_struct_features = lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
5363 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5364 skip |= LogError(
5365 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5366 "vkCopyAccelerationStructureToMemoryKHR: The "
5367 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5368 }
5369 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5370 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5371 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5372 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5373 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5374 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005375 return skip;
5376}
5377
5378bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5379 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5380 bool skip = false;
5381 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5382 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5383 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5384 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5385 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005386 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5387 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
5388 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.",
5389 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005390 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005391 return skip;
5392}
5393
5394bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5395 const char *api_name) const {
5396 bool skip = false;
5397 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5398 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5399 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5400 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5401 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5402 api_name);
5403 }
5404 return skip;
5405}
5406
5407bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005408 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005409 bool skip = false;
5410 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmarcd5fb182020-07-17 12:58:44 -07005411 const auto *acc_struct_features = lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
5412 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005413 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005414 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5415 "vkCopyAccelerationStructureKHR: The "
5416 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005417 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005418 return skip;
5419}
5420
5421bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5422 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5423 bool skip = false;
5424 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5425 return skip;
5426}
5427
5428bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005429 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005430 bool skip = false;
5431 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07005432 skip |= LogError(device,
sourav parmarcd5fb182020-07-17 12:58:44 -07005433 "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005434 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5435 }
5436 return skip;
5437}
5438
5439bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005440 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005441 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005442 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
sourav parmarcd5fb182020-07-17 12:58:44 -07005443 const auto *acc_struct_features = lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
5444 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5445 skip |= LogError(
5446 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5447 "vkCopyMemoryToAccelerationStructureKHR: The "
5448 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005449 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005450 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
5451 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07005452 return skip;
5453}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005454
sourav parmara96ab1a2020-04-25 16:28:23 -07005455bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5456 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5457 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005458 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07005459 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
5460 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
5461 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.",
5462 pInfo->src.deviceAddress);
5463 }
sourav parmar83c31b12020-05-06 12:30:54 -07005464 return skip;
5465}
5466bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5467 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5468 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5469 bool skip = false;
5470 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5471 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5472 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5473 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5474 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5475 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5476 }
5477 return skip;
5478}
5479bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5480 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5481 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5482 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005483 const auto *acc_structure_features =
5484 lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
5485 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
5486 skip |= LogError(
5487 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
5488 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
5489 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5490 }
sourav parmar83c31b12020-05-06 12:30:54 -07005491 if (dataSize < accelerationStructureCount * stride) {
5492 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5493 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5494 "accelerationStructureCount (%d) *stride(%zu).",
5495 dataSize, accelerationStructureCount, stride);
5496 }
5497 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5498 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5499 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5500 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5501 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5502 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5503 }
5504 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5505 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5506 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5507 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5508 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5509 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5510 stride);
5511 }
5512 }
5513 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5514 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5515 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5516 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5517 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5518 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5519 stride);
5520 }
5521 }
sourav parmar83c31b12020-05-06 12:30:54 -07005522 return skip;
5523}
5524bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5525 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5526 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005527 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
5528 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
5529 skip |= LogError(
5530 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
5531 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
5532 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07005533 }
5534 return skip;
5535}
5536
5537bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07005538 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5539 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
5540 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5541 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07005542 uint32_t width, uint32_t height, uint32_t depth) const {
5543 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005544 // RayGen
5545 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5546 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
5547 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005548 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005549 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5550 0) {
5551 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
5552 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5553 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5554 }
5555 // Callable
5556 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5557 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
5558 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5559 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005560 }
5561 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5562 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5563 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005564 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5565 }
5566 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5567 0) {
5568 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
5569 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5570 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005571 }
5572 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005573 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5574 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
5575 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5576 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005577 }
5578 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5579 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005580 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
5581 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07005582 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005583 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5584 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
5585 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5586 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5587 }
sourav parmar83c31b12020-05-06 12:30:54 -07005588 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005589 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5590 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
5591 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
5592 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07005593 }
5594 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5595 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5596 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005597 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5598 }
5599 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5600 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
5601 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5602 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5603 }
5604 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
5605 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
5606 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
5607 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
5608 }
5609 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
5610 skip |=
5611 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
5612 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
5613 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07005614 }
5615
sourav parmarcd5fb182020-07-17 12:58:44 -07005616 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
5617 skip |=
5618 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
5619 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
5620 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
5621 }
5622
5623 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
5624 skip |=
5625 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
5626 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
5627 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07005628 }
5629 return skip;
5630}
5631
sourav parmarcd5fb182020-07-17 12:58:44 -07005632bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
5633 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5634 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5635 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005636 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005637 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
5638 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
5639 skip |= LogError(
5640 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
5641 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
5642 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005643 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005644 // RayGen
5645 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5646 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
5647 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005648 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005649 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5650 0) {
5651 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
5652 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5653 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5654 }
5655 // Callabe
5656 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5657 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
5658 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5659 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005660 }
5661 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5662 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07005663 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
5664 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5665 }
5666 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5667 0) {
5668 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
5669 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5670 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005671 }
5672 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005673 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5674 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
5675 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5676 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005677 }
5678 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5679 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005680 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
5681 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07005682 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005683 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5684 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
5685 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5686 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5687 }
sourav parmar83c31b12020-05-06 12:30:54 -07005688 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005689 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5690 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
5691 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
5692 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005693 }
5694 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5695 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07005696 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
5697 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5698 }
5699 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5700 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
5701 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5702 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005703 }
5704
sourav parmarcd5fb182020-07-17 12:58:44 -07005705 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
5706 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
5707 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07005708 }
5709 return skip;
5710}
5711bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5712 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5713 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5714 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5715 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5716 uint32_t width, uint32_t height, uint32_t depth) const {
5717 bool skip = false;
5718 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5719 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5720 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5721 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5722 }
5723 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5724 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5725 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5726 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5727 }
5728 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5729 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5730 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5731 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5732 }
5733
5734 // hitShader
5735 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5736 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5737 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5738 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5739 }
5740 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5741 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5742 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5743 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5744 }
5745 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5746 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5747 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5748 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5749 }
5750
5751 // missShader
5752 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5753 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5754 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5755 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5756 }
5757 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5758 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5759 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5760 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5761 }
5762 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5763 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5764 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5765 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5766 }
5767
5768 // raygenShader
5769 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5770 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5771 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005772 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5773 }
5774 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5775 skip |=
5776 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5777 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5778 }
5779 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5780 skip |=
5781 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5782 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5783 }
5784 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5785 skip |=
5786 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5787 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005788 }
5789 return skip;
5790}
5791
sourav parmar83c31b12020-05-06 12:30:54 -07005792bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005793 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
5794 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005795 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005796 const auto *ray_query_features = lvl_find_in_chain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005797 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005798 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
5799 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005800 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07005801 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5802 }
5803 return skip;
5804}
5805
Piers Daniell39842ee2020-07-10 16:42:33 -06005806bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5807 const VkViewport *pViewports) const {
5808 bool skip = false;
5809
5810 if (!physical_device_features.multiViewport) {
5811 if (viewportCount != 1) {
5812 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5813 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5814 ") is not 1.",
5815 viewportCount);
5816 }
5817 } else { // multiViewport enabled
5818 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5819 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5820 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5821 ") must "
5822 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5823 viewportCount, device_limits.maxViewports);
5824 }
5825 }
5826
5827 if (pViewports) {
5828 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5829 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5830 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5831 skip |= manual_PreCallValidateViewport(
5832 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5833 }
5834 }
5835
5836 return skip;
5837}
5838
5839bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5840 const VkRect2D *pScissors) const {
5841 bool skip = false;
5842
5843 if (!physical_device_features.multiViewport) {
5844 if (scissorCount != 1) {
5845 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
5846 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5847 ") must "
5848 "be 1 when the multiViewport feature is disabled.",
5849 scissorCount);
5850 }
5851 } else { // multiViewport enabled
5852 if (scissorCount == 0) {
5853 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5854 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5855 ") must "
5856 "be great than zero.",
5857 scissorCount);
5858 } else if (scissorCount > device_limits.maxViewports) {
5859 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5860 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5861 ") must "
5862 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5863 scissorCount, device_limits.maxViewports);
5864 }
5865 }
5866
5867 if (pScissors) {
5868 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
5869 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
5870
5871 if (scissor.offset.x < 0) {
5872 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5873 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
5874 scissor.offset.x);
5875 }
5876
5877 if (scissor.offset.y < 0) {
5878 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5879 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
5880 scissor.offset.y);
5881 }
5882
5883 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5884 if (x_sum > INT32_MAX) {
5885 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
5886 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5887 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5888 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
5889 }
5890
5891 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5892 if (y_sum > INT32_MAX) {
5893 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
5894 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5895 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5896 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
5897 }
5898 }
5899 }
5900
5901 return skip;
5902}
5903
5904bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5905 uint32_t bindingCount, const VkBuffer *pBuffers,
5906 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
5907 const VkDeviceSize *pStrides) const {
5908 bool skip = false;
5909 if (firstBinding >= device_limits.maxVertexInputBindings) {
5910 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
5911 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
5912 firstBinding, device_limits.maxVertexInputBindings);
5913 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5914 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
5915 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5916 "maxVertexInputBindings (%u)",
5917 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5918 }
5919
5920 for (uint32_t i = 0; i < bindingCount; ++i) {
5921 if (pBuffers[i] == VK_NULL_HANDLE) {
5922 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
5923 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5924 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
5925 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5926 } else {
5927 if (pOffsets[i] != 0) {
5928 skip |=
5929 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
5930 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5931 }
5932 }
5933 }
5934 if (pStrides) {
5935 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
5936 skip |=
5937 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
5938 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
5939 pStrides[i], device_limits.maxVertexInputBindingStride);
5940 }
5941 }
5942 }
5943
5944 return skip;
5945}
sourav parmarcd5fb182020-07-17 12:58:44 -07005946
5947bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
5948 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
5949 bool skip = false;
5950 for (uint32_t i = 0; i < infoCount; ++i) {
5951 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5952 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
5953 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
5954 }
5955 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
5956 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
5957 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
5958 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
5959 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
5960 api_name);
5961 }
5962 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
5963 skip |=
5964 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
5965 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
5966 }
5967 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
5968 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
5969 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
5970 }
5971 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
5972 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
5973 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
5974 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
5975 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
5976 api_name);
5977 }
5978 if (pInfos[i].pGeometries) {
5979 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
5980 skip |= validate_ranged_enum(
5981 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
5982 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
5983 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
5984 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
5985 if (pInfos[i].pGeometries[j].geometry.triangles.maxVertex <= 0) {
5986 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-maxVertex-03655",
5987 "(%s): maxVertex must be greater than 0", api_name);
5988 }
5989 skip |= validate_struct_type(
5990 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
5991 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
5992 &(pInfos[i].pGeometries[j].geometry.triangles),
5993 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
5994 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
5995 skip |= validate_struct_pnext(
5996 api_name,
5997 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
5998 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
5999 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6000 skip |=
6001 validate_ranged_enum(api_name,
6002 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6003 ParameterName::IndexVector{i, j}),
6004 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6005 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6006 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6007 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6008 &pInfos[i].pGeometries[j].geometry.triangles,
6009 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6010 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6011 skip |= validate_ranged_enum(
6012 api_name,
6013 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6014 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6015 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6016
6017 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6018 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6019 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6020 }
6021 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6022 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6023 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6024 skip |=
6025 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6026 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6027 api_name);
6028 }
6029 }
6030 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6031 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6032 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6033 &pInfos[i].pGeometries[j].geometry.instances,
6034 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6035 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6036 skip |= validate_struct_type(
6037 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6038 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6039 &(pInfos[i].pGeometries[j].geometry.instances),
6040 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6041 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6042 skip |= validate_struct_pnext(
6043 api_name,
6044 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6045 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6046 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6047
6048 skip |= validate_bool32(api_name,
6049 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6050 ParameterName::IndexVector{i, j}),
6051 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6052 }
6053 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6054 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6055 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6056 &pInfos[i].pGeometries[j].geometry.aabbs,
6057 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6058 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6059 skip |= validate_struct_type(
6060 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6061 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6062 &(pInfos[i].pGeometries[j].geometry.aabbs),
6063 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6064 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6065 skip |= validate_struct_pnext(
6066 api_name,
6067 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6068 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6069 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6070 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6071 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6072 "(%s):stride must be less than or equal to 2^32-1", api_name);
6073 }
6074 }
6075 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6076 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6077 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6078 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6079 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6080 api_name);
6081 }
6082 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6083 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6084 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6085 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6086 "of elements of"
6087 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6088 api_name);
6089 }
6090 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6091 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6092 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6093 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6094 api_name);
6095 }
6096 }
6097 }
6098 }
6099 if (pInfos[i].ppGeometries != NULL) {
6100 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6101 skip |= validate_ranged_enum(
6102 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6103 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6104 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6105 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6106 if (pInfos[i].ppGeometries[j]->geometry.triangles.maxVertex <= 0) {
6107 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-maxVertex-03655",
6108 "(%s): maxVertex must be greater than 0", api_name);
6109 }
6110 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6111 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6112 &pInfos[i].ppGeometries[j]->geometry.triangles,
6113 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6114 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6115 skip |= validate_struct_type(
6116 api_name,
6117 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6118 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6119 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6120 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6121 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6122 skip |= validate_struct_pnext(
6123 api_name,
6124 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6125 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6126 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6127 skip |= validate_ranged_enum(api_name,
6128 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6129 ParameterName::IndexVector{i, j}),
6130 "VkFormat", AllVkFormatEnums,
6131 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6132 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6133 skip |= validate_ranged_enum(api_name,
6134 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6135 ParameterName::IndexVector{i, j}),
6136 "VkIndexType", AllVkIndexTypeEnums,
6137 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6138 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6139 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6140 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6141 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6142 }
6143 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6144 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6145 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6146 skip |=
6147 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6148 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6149 api_name);
6150 }
6151 }
6152 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6153 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6154 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6155 &pInfos[i].ppGeometries[j]->geometry.instances,
6156 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6157 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6158 skip |= validate_struct_type(
6159 api_name,
6160 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6161 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6162 &(pInfos[i].ppGeometries[j]->geometry.instances),
6163 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6164 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6165 skip |= validate_struct_pnext(
6166 api_name,
6167 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6168 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6169 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6170 skip |= validate_bool32(api_name,
6171 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6172 ParameterName::IndexVector{i, j}),
6173 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6174 }
6175 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6176 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6177 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6178 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6179 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6180 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6181 skip |= validate_struct_type(
6182 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6183 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6184 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6185 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6186 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6187 skip |= validate_struct_pnext(
6188 api_name,
6189 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6190 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6191 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6192 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6193 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6194 "(%s):stride must be less than or equal to 2^32-1", api_name);
6195 }
6196 }
6197 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6198 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6199 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6200 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6201 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6202 api_name);
6203 }
6204 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6205 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6206 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6207 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6208 "of elements of"
6209 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6210 api_name);
6211 }
6212 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6213 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6214 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6215 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6216 api_name);
6217 }
6218 }
6219 }
6220 }
6221 }
6222 return skip;
6223}
6224bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6225 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6226 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6227 bool skip = false;
6228 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6229 for (uint32_t i = 0; i < infoCount; ++i) {
6230 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6231 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6232 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6233 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6234 "scratchData.deviceAddress member must be a multiple of "
6235 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6236 }
6237 for (uint32_t k = 0; k < infoCount; ++k) {
6238 if (i == k) continue;
6239 bool found = false;
6240 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6241 skip |= LogError(
6242 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6243 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6244 "not be "
6245 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6246 i, k);
6247 found = true;
6248 }
6249 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6250 skip |= LogError(
6251 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6252 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6253 "not be "
6254 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6255 i, k);
6256 found = true;
6257 }
6258 if (found) break;
6259 }
6260 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6261 if (pInfos[i].pGeometries) {
6262 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6263 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6264 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6265 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6266 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6267 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6268 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6269 }
6270 } else {
6271 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6272 skip |=
6273 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6274 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6275 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6276 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6277 }
6278 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006279 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006280 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6281 skip |= LogError(
6282 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6283 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6284 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6285 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006286 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6287 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006288 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6289 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6290 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6291 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6292 }
6293 }
6294 } else if (pInfos[i].ppGeometries) {
6295 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6296 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6297 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6298 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6299 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6300 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6301 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6302 }
6303 } else {
6304 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6305 skip |=
6306 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6307 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6308 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6309 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6310 }
6311 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006312 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006313 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6314 skip |= LogError(
6315 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6316 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6317 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6318 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006319 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6320 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006321 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6322 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6323 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6324 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6325 }
6326 }
6327 }
6328 }
6329 }
6330 return skip;
6331}
6332
6333bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6334 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6335 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6336 const uint32_t *const *ppMaxPrimitiveCounts) const {
6337 bool skip = false;
6338 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6339 const auto *ray_tracing_acceleration_structure_features =
6340 lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
6341 if (!ray_tracing_acceleration_structure_features ||
6342 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6343 skip |= LogError(
6344 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6345 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6346 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6347 }
6348 for (uint32_t i = 0; i < infoCount; ++i) {
6349 if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) {
6350 if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) {
6351 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666",
6352 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is "
6353 "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be "
6354 "VK_NULL_HANDLE.");
6355 }
6356 }
6357 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6358 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6359 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6360 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6361 "scratchData.deviceAddress member must be a multiple of "
6362 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6363 }
6364 for (uint32_t k = 0; k < infoCount; ++k) {
6365 if (i == k) continue;
6366 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6367 skip |=
6368 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6369 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6370 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6371 "any other element [%d) of pInfos.",
6372 i, k);
6373 break;
6374 }
6375 }
6376 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6377 if (pInfos[i].pGeometries) {
6378 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6379 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6380 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6381 skip |= LogError(
6382 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6383 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6384 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6385 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6386 }
6387 } else {
6388 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6389 skip |= LogError(
6390 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6391 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6392 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6393 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6394 }
6395 }
6396 }
6397 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6398 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6399 skip |= LogError(
6400 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6401 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6402 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6403 }
6404 }
6405 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6406 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6407 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6408 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6409 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6410 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6411 }
6412 }
6413 } else if (pInfos[i].ppGeometries) {
6414 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6415 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6416 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6417 skip |= LogError(
6418 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6419 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6420 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6421 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6422 }
6423 } else {
6424 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6425 skip |= LogError(
6426 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6427 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6428 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6429 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6430 }
6431 }
6432 }
6433 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6434 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6435 skip |= LogError(
6436 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6437 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6438 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6439 }
6440 }
6441 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6442 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6443 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6444 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6445 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6446 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6447 }
6448 }
6449 }
6450 }
6451 }
6452 return skip;
6453}
6454
6455bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6456 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6457 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6458 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6459 bool skip = false;
6460 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6461 const auto *ray_tracing_acceleration_structure_features =
6462 lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
6463 if (!ray_tracing_acceleration_structure_features ||
6464 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6465 skip |=
6466 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
6467 "vkBuildAccelerationStructuresKHR: The "
6468 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
6469 }
6470 for (uint32_t i = 0; i < infoCount; ++i) {
6471 for (uint32_t j = 0; j < infoCount; ++j) {
6472 if (i == j) continue;
6473 bool found = false;
6474 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6475 skip |= LogError(
6476 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6477 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
6478 "not be "
6479 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6480 i, j);
6481 found = true;
6482 }
6483 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6484 skip |= LogError(
6485 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
6486 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
6487 "not be "
6488 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6489 i, j);
6490 found = true;
6491 }
6492 if (found) break;
6493 }
6494 }
6495 return skip;
6496}
6497
6498bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
6499 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
6500 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
6501 bool skip = false;
6502 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
6503 const auto *ray_tracing_pipeline_features =
6504 lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
6505 const auto *ray_query_features = lvl_find_in_chain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6506 if (!(ray_tracing_pipeline_features || ray_query_features) ||
6507 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
6508 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
6509 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
6510 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
6511 }
6512 return skip;
6513}